Slocal uses rcvpack now. Code beautification in slocal.
authormarkus schnalke <meillo@marmaro.de>
Wed, 21 Mar 2012 14:52:15 +0000 (15:52 +0100)
committermarkus schnalke <meillo@marmaro.de>
Wed, 21 Mar 2012 14:52:15 +0000 (15:52 +0100)
config/config.c
h/mh.h
man/slocal.man1
uip/Makefile.in
uip/slocal.c

index 158dd7a..946ea6b 100644 (file)
@@ -168,6 +168,12 @@ char *postproc = NMHBINDIR"/spost";
 char *rcvstoreproc = NMHBINDIR"/rcvstore";
 
 /*
 char *rcvstoreproc = NMHBINDIR"/rcvstore";
 
 /*
+** This is program is called by slocal to handle
+** the action `file', `mbox' or `>'.
+*/
+char *rcvpackproc = NMHBINDIR"/rcvpack";
+
+/*
 ** This program is called to remove a message by rmm or refile -nolink.
 ** It's usually empty, which means to rename the file to a backup name.
 */
 ** This program is called to remove a message by rmm or refile -nolink.
 ** It's usually empty, which means to rename the file to a backup name.
 */
diff --git a/h/mh.h b/h/mh.h
index 23b340a..39684af 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -323,6 +323,7 @@ extern char *postproc;
 extern char *profile;
 extern char *psequence;
 extern char *rcvdistcomps;
 extern char *profile;
 extern char *psequence;
 extern char *rcvdistcomps;
+extern char *rcvpackproc;
 extern char *rcvstoreproc;
 extern char *replcomps;
 extern char *replgroupcomps;
 extern char *rcvstoreproc;
 extern char *replcomps;
 extern char *replgroupcomps;
index c5cf7cf..aea64e4 100644 (file)
@@ -184,12 +184,15 @@ and time that message was delivered.
 This action always succeeds.
 .TP 4
 .IR file ", " mbox ", or " >
 This action always succeeds.
 .TP 4
 .IR file ", " mbox ", or " >
-Append the message to the file named by
+Append the message to the mbox file named by
 .IR string .
 .IR string .
-The message is
-appended to the file in mbox (uucp) format.  This is the format used by most
-other mail clients (such as mailx, elm).  If the message can be appended to
-the file, then this action succeeds.
+This is handled by piping the message to the
+.B nmh
+program
+.BR rcvpack .
+If
+.B rcvpack
+returned successful, then this action succeeds.
 .TP 4
 .IR pipe " or " |
 Pipe the message as the standard input to the command named by
 .TP 4
 .IR pipe " or " |
 Pipe the message as the standard input to the command named by
@@ -230,11 +233,13 @@ Store the message in the
 .B nmh
 folder named by
 .IR string .
 .B nmh
 folder named by
 .IR string .
-Currently this is handled by piping the message to the
+This is handled by piping the message to the
 .B nmh
 program
 .B nmh
 program
-.BR rcvstore ,
-although this may change in the future.
+.BR rcvstore .
+If
+.B rcvstore
+returned successful, then this action succeeds.
 .RE
 .PP
 .BR result :
 .RE
 .PP
 .BR result :
index e53df57..bd114ce 100644 (file)
@@ -218,8 +218,8 @@ show: show.o $(LOCALLIBS)
 slocal.o: slocal.c
        $(COMPILE2) $(srcdir)/slocal.c
 
 slocal.o: slocal.c
        $(COMPILE2) $(srcdir)/slocal.c
 
-slocal: slocal.o aliasbr.o dropsbr.o $(LOCALLIBS)
-       $(LINK) slocal.o aliasbr.o dropsbr.o $(LINKLIBS)
+slocal: slocal.o $(LOCALLIBS)
+       $(LINK) slocal.o $(LINKLIBS)
 
 sortm: sortm.o $(LOCALLIBS)
        $(LINK) sortm.o $(LINKLIBS)
 
 sortm: sortm.o $(LOCALLIBS)
        $(LINK) sortm.o $(LINKLIBS)
index 4e8c30d..813a3b5 100644 (file)
@@ -21,7 +21,6 @@
 */
 
 #include <h/mh.h>
 */
 
 #include <h/mh.h>
-#include <h/dropsbr.h>
 #include <h/rcvmail.h>
 #include <h/signals.h>
 #include <h/tws.h>
 #include <h/rcvmail.h>
 #include <h/signals.h>
 #include <h/tws.h>
@@ -92,7 +91,7 @@ char *maildelivery = NMHETCDIR"/maildelivery";
 
 
 static int globbed = 0;  /* have we built "vars" table yet? */
 
 
 static int globbed = 0;  /* have we built "vars" table yet? */
-static int parsed = 0;  /* have we built header field table yet   */
+static int parsed = 0;  /* have we built header field table yet */
 static int utmped = 0;  /* have we scanned umtp(x) file yet */
 
 static int verbose = 0;
 static int utmped = 0;  /* have we scanned umtp(x) file yet */
 
 static int verbose = 0;
@@ -204,9 +203,9 @@ main(int argc, char **argv)
        invo_name = mhbasename(*argv);
 
        /* foil search of user profile/context */
        invo_name = mhbasename(*argv);
 
        /* foil search of user profile/context */
-       if (context_foil(NULL) == -1)
+       if (context_foil(NULL) == -1) {
                done(1);
                done(1);
-
+       }
        arguments = getarguments(invo_name, argc, argv, 0);
        argp = arguments;
 
        arguments = getarguments(invo_name, argc, argv, 0);
        argp = arguments;
 
@@ -229,51 +228,60 @@ main(int argc, char **argv)
                                done(1);
 
                        case ADDRSW:
                                done(1);
 
                        case ADDRSW:
-                               if (!(addr = *argp++))
+                               if (!(addr = *argp++)) {
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case INFOSW:
                                continue;
                        case INFOSW:
-                               if (!(info = *argp++))
+                               if (!(info = *argp++)) {
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case USERSW:
                                continue;
                        case USERSW:
-                               if (!(user = *argp++))
+                               if (!(user = *argp++)) {
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case FILESW:
                                continue;
                        case FILESW:
-                               if (!(file = *argp++) || *file == '-')
+                               if (!(file = *argp++) || *file == '-') {
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case SENDERSW:
                                continue;
                        case SENDERSW:
-                               if (!(sender = *argp++))
+                               if (!(sender = *argp++)) {
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        /* allow -xyz arguments */
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case MAILBOXSW:
                                continue;
                        case MAILBOXSW:
-                               if (!(mbox = *argp++) || *mbox == '-')
+                               if (!(mbox = *argp++) || *mbox == '-') {
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
                        case HOMESW:
                                continue;
                        case HOMESW:
-                               if (!(home = *argp++) || *home == '-')
+                               if (!(home = *argp++) || *home == '-') {
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
+                               }
                                continue;
 
                        case MAILSW:
                                continue;
 
                        case MAILSW:
-                               if (!(cp = *argp++) || *cp == '-')
+                               if (!(cp = *argp++) || *cp == '-') {
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
                                        adios(NULL, "missing argument to %s",
                                                        argp[-2]);
-                               if (mdlvr)
+                               }
+                               if (mdlvr) {
                                        adios(NULL, "only one maildelivery file at a time!");
                                        adios(NULL, "only one maildelivery file at a time!");
+                               }
                                mdlvr = cp;
                                continue;
 
                                mdlvr = cp;
                                continue;
 
@@ -303,15 +311,19 @@ main(int argc, char **argv)
                }
        }
 
                }
        }
 
-       if (addr == NULL)
+       if (!addr) {
                addr = getusername();
                addr = getusername();
-       if (user == NULL)
+       }
+       if (!user) {
                user = (cp = strchr(addr, '.')) ? ++cp : addr;
                user = (cp = strchr(addr, '.')) ? ++cp : addr;
-       if ((pw = getpwnam(user)) == NULL)
+       }
+       if (!(pw = getpwnam(user))) {
                adios(NULL, "no such local user as %s", user);
                adios(NULL, "no such local user as %s", user);
+       }
 
 
-       if (chdir(pw->pw_dir) == -1)
+       if (chdir(pw->pw_dir) == -1) {
                chdir("/");
                chdir("/");
+       }
        umask(0077);
 
        if (geteuid() == 0) {
        umask(0077);
 
        if (geteuid() == 0) {
@@ -320,14 +332,16 @@ main(int argc, char **argv)
                setuid(pw->pw_uid);
        }
 
                setuid(pw->pw_uid);
        }
 
-       if (info == NULL)
+       if (!info) {
                info = "";
                info = "";
+       }
 
        setbuf(stdin, NULL);
 
        /* Record the delivery time */
 
        setbuf(stdin, NULL);
 
        /* Record the delivery time */
-       if ((now = dlocaltimenow()) == NULL)
+       if (!(now = dlocaltimenow())) {
                adios(NULL, "unable to ascertain local time");
                adios(NULL, "unable to ascertain local time");
+       }
        snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0));
 
        /*
        snprintf(ddate, sizeof(ddate), "Delivery-Date: %s\n", dtimenow(0));
 
        /*
@@ -337,24 +351,30 @@ main(int argc, char **argv)
                int tempfd;
 
                /* getting message from file */
                int tempfd;
 
                /* getting message from file */
-               if ((tempfd = open(file, O_RDONLY)) == -1)
+               if ((tempfd = open(file, O_RDONLY)) == -1) {
                        adios(file, "unable to open");
                        adios(file, "unable to open");
-               if (debug)
+               }
+               if (debug) {
                        debug_printf("retrieving message from file \"%s\"\n",
                                        file);
                        debug_printf("retrieving message from file \"%s\"\n",
                                        file);
-               if ((fd = copy_message(tempfd, tmpfil, 1)) == -1)
+               }
+               if ((fd = copy_message(tempfd, tmpfil, 1)) == -1) {
                        adios(NULL, "unable to create temporary file");
                        adios(NULL, "unable to create temporary file");
+               }
                close(tempfd);
        } else {
                /* getting message from stdin */
                close(tempfd);
        } else {
                /* getting message from stdin */
-               if (debug)
+               if (debug) {
                        debug_printf("retrieving message from stdin\n");
                        debug_printf("retrieving message from stdin\n");
-               if ((fd = copy_message(fileno(stdin), tmpfil, 1)) == -1)
+               }
+               if ((fd = copy_message(fileno(stdin), tmpfil, 1)) == -1) {
                        adios(NULL, "unable to create temporary file");
                        adios(NULL, "unable to create temporary file");
+               }
        }
 
        }
 
-       if (debug)
+       if (debug) {
                debug_printf("temporary file=\"%s\"\n", tmpfil);
                debug_printf("temporary file=\"%s\"\n", tmpfil);
+       }
 
        /*
        ** Delete the temp file now or a copy of every single message
 
        /*
        ** Delete the temp file now or a copy of every single message
@@ -373,23 +393,22 @@ main(int argc, char **argv)
        */
        unlink(tmpfil);
 
        */
        unlink(tmpfil);
 
-       if (!(fp = fdopen(fd, "r+")))
+       if (!(fp = fdopen(fd, "r+"))) {
                adios(NULL, "unable to access temporary file");
                adios(NULL, "unable to access temporary file");
+       }
 
 
-       /*
-       ** If no sender given, extract it
-       ** from envelope information.
-       */
-       if (sender == NULL)
+       /* If no sender given, extract it from envelope information. */
+       if (!sender) {
                get_sender(envelope, &sender);
                get_sender(envelope, &sender);
-
-       if (mbox == NULL) {
+       }
+       if (!mbox) {
                snprintf(mailbox, sizeof(mailbox), "%s/%s",
                                mailspool, pw->pw_name);
                mbox = mailbox;
        }
                snprintf(mailbox, sizeof(mailbox), "%s/%s",
                                mailspool, pw->pw_name);
                mbox = mailbox;
        }
-       if (home == NULL)
+       if (!home) {
                home = pw->pw_dir;
                home = pw->pw_dir;
+       }
 
        if (debug) {
                debug_printf("addr=\"%s\"\n", trim(addr));
 
        if (debug) {
                debug_printf("addr=\"%s\"\n", trim(addr));
@@ -415,21 +434,20 @@ main(int argc, char **argv)
 /*
 ** Main routine for delivering message.
 */
 /*
 ** Main routine for delivering message.
 */
-
 static int
 localmail(int fd, char *mdlvr)
 {
        /* delivery according to personal Maildelivery file */
 static int
 localmail(int fd, char *mdlvr)
 {
        /* delivery according to personal Maildelivery file */
-       if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1)
+       if (usr_delivery(fd, mdlvr ? mdlvr : ".maildelivery", 0) != -1) {
                return 0;
                return 0;
-
+       }
        /* delivery according to global Maildelivery file */
        /* delivery according to global Maildelivery file */
-       if (usr_delivery(fd, maildelivery, 1) != -1)
+       if (usr_delivery(fd, maildelivery, 1) != -1) {
                return 0;
                return 0;
-
-       if (verbose)
+       }
+       if (verbose) {
                verbose_printf("(delivering to standard mail spool)\n");
                verbose_printf("(delivering to standard mail spool)\n");
-
+       }
        /* last resort - deliver to standard mail spool */
        return usr_file(fd, mbox);
 }
        /* last resort - deliver to standard mail spool */
        return usr_file(fd, mbox);
 }
@@ -440,7 +458,6 @@ localmail(int fd, char *mdlvr)
 /*
 ** Parse the delivery file, and process incoming message.
 */
 /*
 ** Parse the delivery file, and process incoming message.
 */
-
 static int
 usr_delivery(int fd, char *delivery, int su)
 {
 static int
 usr_delivery(int fd, char *delivery, int su)
 {
@@ -453,9 +470,9 @@ usr_delivery(int fd, char *delivery, int su)
        FILE *fp;
 
        /* open the delivery file */
        FILE *fp;
 
        /* open the delivery file */
-       if ((fp = fopen(delivery, "r")) == NULL)
+       if (!(fp = fopen(delivery, "r"))) {
                return -1;
                return -1;
-
+       }
        /* check if delivery file has bad ownership or permissions */
        if (fstat(fileno(fp), &st) == -1 ||
                        (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid)) ||
        /* check if delivery file has bad ownership or permissions */
        if (fstat(fileno(fp), &st) == -1 ||
                        (st.st_uid != 0 && (su || st.st_uid != pw->pw_uid)) ||
@@ -472,13 +489,13 @@ usr_delivery(int fd, char *delivery, int su)
        /* read and process delivery file */
        while (fgets(buffer, sizeof(buffer), fp)) {
                /* skip comments and empty lines */
        /* read and process delivery file */
        while (fgets(buffer, sizeof(buffer), fp)) {
                /* skip comments and empty lines */
-               if (*buffer == '#' || *buffer == '\n')
+               if (*buffer == '#' || *buffer == '\n') {
                        continue;
                        continue;
-
+               }
                /* zap trailing newline */
                /* zap trailing newline */
-               if ((cp = strchr(buffer, '\n')))
-                       *cp = 0;
-
+               if ((cp = strchr(buffer, '\n'))) {
+                       *cp = '\0';
+               }
                /* split buffer into fields */
                vecp = split(buffer, vec);
 
                /* split buffer into fields */
                vecp = split(buffer, vec);
 
@@ -490,9 +507,10 @@ usr_delivery(int fd, char *delivery, int su)
                }
 
                if (debug) {
                }
 
                if (debug) {
-                       for (i = 0; vec[i]; i++)
+                       for (i = 0; vec[i]; i++) {
                                debug_printf("vec[%d]: \"%s\"\n",
                                                i, trim(vec[i]));
                                debug_printf("vec[%d]: \"%s\"\n",
                                                i, trim(vec[i]));
+                       }
                }
 
                field   = vec[0];
                }
 
                field   = vec[0];
@@ -509,8 +527,10 @@ usr_delivery(int fd, char *delivery, int su)
                        ** If previous condition failed, don't
                        ** do this - else fall through
                        */
                        ** If previous condition failed, don't
                        ** do this - else fall through
                        */
-                        if (!next)
-                               continue;  /* else fall */
+                       if (!next) {
+                               continue;
+                       }
+                       /* fall */
 
                case '?':
                        /*
 
                case '?':
                        /*
@@ -518,8 +538,10 @@ usr_delivery(int fd, char *delivery, int su)
                        ** Else consider delivered if action is
                        ** successful.
                        */
                        ** Else consider delivered if action is
                        ** successful.
                        */
-                       if (won)
-                               continue;  /* else fall */
+                       if (won) {
+                               continue;
+                       }
+                       /* fall */
 
                case 'A':
                case 'a':
 
                case 'A':
                case 'a':
@@ -541,32 +563,33 @@ usr_delivery(int fd, char *delivery, int su)
                        break;
                }
 
                        break;
                }
 
-               if (vecp > 5) {
-                       if (!mh_strcasecmp(vec[5], "select")) {
-                               if (logged_in() != -1)
-                                       continue;
-                               if (vecp > 7 && timely(vec[6], vec[7]) == -1)
-                                       continue;
+               if (vecp > 5 && mh_strcasecmp(vec[5], "select")==0) {
+                       if (logged_in() != -1) {
+                               continue;
+                       }
+                       if (vecp > 7 && timely(vec[6], vec[7]) == -1) {
+                               continue;
                        }
                }
 
                /* check if the field matches */
                switch (*field) {
                case '*':
                        }
                }
 
                /* check if the field matches */
                switch (*field) {
                case '*':
-               /* always matches */
+                       /* always matches */
                        break;
 
                case 'd':
                        break;
 
                case 'd':
-               /*
-               ** "default" matches only if the message hasn't
-               ** been delivered yet.
-               */
-                       if (!mh_strcasecmp(field, "default")) {
-                               if (won)
+                       /*
+                       ** "default" matches only if the message hasn't
+                       ** been delivered yet.
+                       */
+                       if (mh_strcasecmp(field, "default")==0) {
+                               if (won) {
                                        continue;
                                        continue;
+                               }
                                break;
                                break;
-                       }  /* else fall */
-
+                       }
+                       /* fall */
                default:
                        /* parse message and build lookup table */
                        if (!parsed && parse(fd) == -1) {
                default:
                        /* parse message and build lookup table */
                        if (!parsed && parse(fd) == -1) {
@@ -577,8 +600,8 @@ usr_delivery(int fd, char *delivery, int su)
                        ** find header field in lookup table, and
                        ** see if the pattern matches.
                        */
                        ** find header field in lookup table, and
                        ** see if the pattern matches.
                        */
-                       if ((p = lookup(hdrs, field)) && (p->p_value != NULL)
-                                       && matches(p->p_value, pattern)) {
+                       if ((p = lookup(hdrs, field)) && p->p_value &&
+                                       matches(p->p_value, pattern)) {
                                next = 1;
                        } else {
                                next = 0;
                                next = 1;
                        } else {
                                next = 0;
@@ -591,47 +614,54 @@ usr_delivery(int fd, char *delivery, int su)
                switch (*action) {
                case 'q':
                        /* deliver to quoted pipe */
                switch (*action) {
                case 'q':
                        /* deliver to quoted pipe */
-                       if (mh_strcasecmp(action, "qpipe"))
-                               continue;  /* else fall */
+                       if (mh_strcasecmp(action, "qpipe")) {
+                               continue;
+                       }
+                       /* fall */
                case '^':
                        expand(tmpbuf, string, fd);
                case '^':
                        expand(tmpbuf, string, fd);
-                       if (split(tmpbuf, vec) < 1)
+                       if (split(tmpbuf, vec) < 1) {
                                continue;
                                continue;
+                       }
                        status = usr_pipe(fd, tmpbuf, vec[0], vec, 0);
                        break;
 
                case 'p':
                        /* deliver to pipe */
                        status = usr_pipe(fd, tmpbuf, vec[0], vec, 0);
                        break;
 
                case 'p':
                        /* deliver to pipe */
-                       if (mh_strcasecmp(action, "pipe"))
-                               continue;  /* else fall */
+                       if (mh_strcasecmp(action, "pipe")) {
+                               continue;
+                       }
+                       /* fall */
                case '|':
                        vec[2] = "sh";
                        vec[3] = "-c";
                        expand(tmpbuf, string, fd);
                        vec[4] = tmpbuf;
                        vec[5] = NULL;
                case '|':
                        vec[2] = "sh";
                        vec[3] = "-c";
                        expand(tmpbuf, string, fd);
                        vec[4] = tmpbuf;
                        vec[5] = NULL;
-                       status = usr_pipe(fd, tmpbuf, "/bin/sh",
-                                       vec + 2, 0);
+                       status = usr_pipe(fd, tmpbuf, "/bin/sh", vec+2, 0);
                        break;
 
                case 'f':
                        break;
 
                case 'f':
-                       /* mbox format */
-                       if (!mh_strcasecmp(action, "file")) {
+                       if (mh_strcasecmp(action, "file")==0) {
+                               /* mbox format */
                                status = usr_file(fd, string);
                                break;
                        }
                                status = usr_file(fd, string);
                                break;
                        }
-                       /* deliver to nmh folder */
-                       else if (mh_strcasecmp(action, "folder"))
-                               continue;  /* else fall */
+                       if (mh_strcasecmp(action, "folder")!=0) {
+                               continue;
+                       }
+                       /* fall */
                case '+':
                case '+':
+                       /* deliver to nmh folder */
                        status = usr_folder(fd, string);
                        break;
 
                case 'm':
                        /* mbox format */
                        status = usr_folder(fd, string);
                        break;
 
                case 'm':
                        /* mbox format */
-                       if (mh_strcasecmp(action, "mbox"))
-                               continue;  /* else fall */
-
+                       if (mh_strcasecmp(action, "mbox")!=0) {
+                               continue;
+                       }
+                       /* fall */
                case '>':
                        /* mbox format */
                        status = usr_file(fd, string);
                case '>':
                        /* mbox format */
                        status = usr_file(fd, string);
@@ -639,17 +669,18 @@ usr_delivery(int fd, char *delivery, int su)
 
                case 'd':
                        /* ignore message */
 
                case 'd':
                        /* ignore message */
-                       if (mh_strcasecmp(action, "destroy"))
+                       if (mh_strcasecmp(action, "destroy")!=0) {
                                continue;
                                continue;
+                       }
                        status = 0;
                        break;
                }
 
                        status = 0;
                        break;
                }
 
-               if (status)
+               if (status) {
                        next = 0;  /* action failed, mark for 'N' result */
                        next = 0;  /* action failed, mark for 'N' result */
-
-               if (accept && status == 0)
+               } else if (accept) {
                        won++;
                        won++;
+               }
        }
 
        fclose(fp);
        }
 
        fclose(fp);
@@ -657,13 +688,10 @@ usr_delivery(int fd, char *delivery, int su)
 }
 
 
 }
 
 
-#define QUOTE  '\\'
-
 /*
 ** Split buffer into fields (delimited by whitespace or
 ** comma's).  Return the number of fields found.
 */
 /*
 ** Split buffer into fields (delimited by whitespace or
 ** comma's).  Return the number of fields found.
 */
-
 static int
 split(char *cp, char **vec)
 {
 static int
 split(char *cp, char **vec)
 {
@@ -677,13 +705,13 @@ split(char *cp, char **vec)
                vec[i] = NULL;
 
                /* zap any whitespace and comma's */
                vec[i] = NULL;
 
                /* zap any whitespace and comma's */
-               while (isspace(*s) || *s == ',')
-                       *s++ = 0;
-
+               while (isspace(*s) || *s == ',') {
+                       *s++ = '\0';
+               }
                /* end of buffer, time to leave */
                /* end of buffer, time to leave */
-               if (*s == 0)
+               if (!*s) {
                        break;
                        break;
-
+               }
                /* get double quote text as a single field */
                if (*s == '"') {
                        for (vec[i++] = ++s; *s && *s != '"'; s++) {
                /* get double quote text as a single field */
                if (*s == '"') {
                        for (vec[i++] = ++s; *s && *s != '"'; s++) {
@@ -691,24 +719,29 @@ split(char *cp, char **vec)
                                ** Check for escaped double quote.  We need
                                ** to shift the string to remove slash.
                                */
                                ** Check for escaped double quote.  We need
                                ** to shift the string to remove slash.
                                */
-                               if (*s == QUOTE) {
-                                       if (*++s == '"')
+                               if (*s == '\\') {
+                                       if (*++s == '"') {
                                                strcpy(s - 1, s);
                                                strcpy(s - 1, s);
+                                       }
                                        s--;
                                }
                        }
                                        s--;
                                }
                        }
-                       if (*s == '"')  /* zap trailing double quote */
-                               *s++ = 0;
+                       if (*s == '"') {
+                               /* zap trailing double quote */
+                               *s++ = '\0';
+                       }
                        continue;
                }
 
                        continue;
                }
 
-               if (*s == QUOTE && *++s != '"')
+               if (*s == '\\' && *++s != '"') {
                        s--;
                        s--;
+               }
                vec[i++] = s++;
 
                /* move forward to next field delimiter */
                vec[i++] = s++;
 
                /* move forward to next field delimiter */
-               while (*s && !isspace(*s) && *s != ',')
+               while (*s && !isspace(*s) && *s != ',') {
                        s++;
                        s++;
+               }
        }
        vec[i] = NULL;
 
        }
        vec[i] = NULL;
 
@@ -720,7 +753,6 @@ split(char *cp, char **vec)
 ** Parse the headers of a message, and build the
 ** lookup table for matching fields and patterns.
 */
 ** Parse the headers of a message, and build the
 ** lookup table for matching fields and patterns.
 */
-
 static int
 parse(int fd)
 {
 static int
 parse(int fd)
 {
@@ -731,28 +763,31 @@ parse(int fd)
        struct pair *p, *q;
        FILE  *in;
 
        struct pair *p, *q;
        FILE  *in;
 
-       if (parsed++)
+       if (parsed++) {
                return 0;
                return 0;
+       }
 
        /* get a new FILE pointer to message */
 
        /* get a new FILE pointer to message */
-       if ((fd1 = dup(fd)) == -1)
+       if ((fd1 = dup(fd)) == -1) {
                return -1;
                return -1;
-       if ((in = fdopen(fd1, "r")) == NULL) {
+       }
+       if (!(in = fdopen(fd1, "r"))) {
                close(fd1);
                return -1;
        }
        rewind(in);
 
        /* add special entries to lookup table */
                close(fd1);
                return -1;
        }
        rewind(in);
 
        /* add special entries to lookup table */
-       if ((p = lookup(hdrs, "source")))
+       if ((p = lookup(hdrs, "source"))) {
                p->p_value = getcpy(sender);
                p->p_value = getcpy(sender);
-       if ((p = lookup(hdrs, "addr")))
+       }
+       if ((p = lookup(hdrs, "addr"))) {
                p->p_value = getcpy(addr);
                p->p_value = getcpy(addr);
+       }
 
        /*
 
        /*
-        * Scan the headers of the message and build
-        * a lookup table.
-        */
+       ** Scan the headers of the message and build a lookup table.
+       */
        for (i = 0, state = FLD;;) {
                switch (state = m_getfld(state, name, field, sizeof(field),
                                in)) {
        for (i = 0, state = FLD;;) {
                switch (state = m_getfld(state, name, field, sizeof(field),
                                in)) {
@@ -766,13 +801,14 @@ parse(int fd)
                                lp = add(field, lp);
                        }
                        for (p = hdrs; p->p_name; p++) {
                                lp = add(field, lp);
                        }
                        for (p = hdrs; p->p_name; p++) {
-                               if (!mh_strcasecmp(p->p_name, name)) {
+                               if (mh_strcasecmp(p->p_name, name)!=0) {
                                        if (!(p->p_flags & P_HID)) {
                                                if ((cp = p->p_value)) {
                                                        if (p->p_flags & P_ADR) {
                                                                dp = cp + strlen(cp) - 1;
                                        if (!(p->p_flags & P_HID)) {
                                                if ((cp = p->p_value)) {
                                                        if (p->p_flags & P_ADR) {
                                                                dp = cp + strlen(cp) - 1;
-                                                               if (*dp == '\n')
-                                                                       *dp = 0;
+                                                               if (*dp == '\n') {
+                                                                       *dp = '\0';
+                                                               }
                                                                cp = add(",\n\t", cp);
                                                        } else {
                                                                cp = add("\t", cp);
                                                                cp = add(",\n\t", cp);
                                                        } else {
                                                                cp = add("\t", cp);
@@ -784,15 +820,16 @@ parse(int fd)
                                        break;
                                }
                        }
                                        break;
                                }
                        }
-                       if (p->p_name == NULL && i < NVEC) {
+                       if (!p->p_name && i < NVEC) {
                                p->p_name = getcpy(name);
                                p->p_value = lp;
                                p->p_flags = P_NIL;
                                p++, i++;
                                p->p_name = NULL;
                        }
                                p->p_name = getcpy(name);
                                p->p_value = lp;
                                p->p_flags = P_NIL;
                                p++, i++;
                                p->p_name = NULL;
                        }
-                       if (state != FLDEOF)
+                       if (state != FLDEOF) {
                                continue;
                                continue;
+                       }
                        break;
 
                case BODY:
                        break;
 
                case BODY:
@@ -815,64 +852,62 @@ parse(int fd)
        fclose(in);
 
        if ((p = lookup(vars, "reply-to"))) {
        fclose(in);
 
        if ((p = lookup(vars, "reply-to"))) {
-               if ((q = lookup(hdrs, "reply-to")) == NULL ||
-                               q->p_value == NULL)
+               if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
                        q = lookup(hdrs, "from");
                        q = lookup(hdrs, "from");
+               }
                p->p_value = getcpy(q ? q->p_value : "");
                p->p_flags &= ~P_CHK;
                p->p_value = getcpy(q ? q->p_value : "");
                p->p_flags &= ~P_CHK;
-               if (debug)
+               if (debug) {
                        debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
                                        p - vars, p->p_name, trim(p->p_value));
                        debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
                                        p - vars, p->p_name, trim(p->p_value));
+               }
        }
        if (debug) {
        }
        if (debug) {
-               for (p = hdrs; p->p_name; p++)
+               for (p = hdrs; p->p_name; p++) {
                        debug_printf("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
                        debug_printf("hdrs[%d]: name=\"%s\" value=\"%s\"\n",
-                               p - hdrs, p->p_name,
-                               p->p_value ? trim(p->p_value) : "");
+                                       p - hdrs, p->p_name,
+                                       p->p_value ? trim(p->p_value) : "");
+               }
        }
        }
-
        return 0;
 }
 
 
        return 0;
 }
 
 
-#define LPAREN '('
-#define RPAREN ')'
-
 /*
 ** Expand any builtin variables such as $(sender),
 ** $(address), etc., in a string.
 */
 /*
 ** Expand any builtin variables such as $(sender),
 ** $(address), etc., in a string.
 */
-
 static void
 expand(char *s1, char *s2, int fd)
 {
        char c, *cp;
        struct pair *p;
 
 static void
 expand(char *s1, char *s2, int fd)
 {
        char c, *cp;
        struct pair *p;
 
-       if (!globbed)
+       if (!globbed) {
                glob(fd);
                glob(fd);
-
+       }
        while ((c = *s2++)) {
        while ((c = *s2++)) {
-               if (c != '$' || *s2 != LPAREN) {
+               if (c != '$' || *s2 != '(') {
                        *s1++ = c;
                } else {
                        *s1++ = c;
                } else {
-                       for (cp = ++s2; *s2 && *s2 != RPAREN; s2++)
+                       for (cp = ++s2; *s2 && *s2 != ')'; s2++) {
                                continue;
                                continue;
-                       if (*s2 != RPAREN) {
+                       }
+                       if (*s2 != ')') {
                                s2 = --cp;
                                continue;
                        }
                                s2 = --cp;
                                continue;
                        }
-                       *s2++ = 0;
+                       *s2++ = '\0';
                        if ((p = lookup(vars, cp))) {
                        if ((p = lookup(vars, cp))) {
-                               if (!parsed && (p->p_flags & P_CHK))
+                               if (!parsed && (p->p_flags & P_CHK)) {
                                        parse(fd);
                                        parse(fd);
-
+                               }
                                strcpy(s1, p->p_value);
                                s1 += strlen(s1);
                        }
                }
        }
                                strcpy(s1, p->p_value);
                                s1 += strlen(s1);
                        }
                }
        }
-       *s1 = 0;
+       *s1 = '\0';
 }
 
 
 }
 
 
@@ -882,7 +917,6 @@ expand(char *s1, char *s2, int fd)
 ** variables in the string for a "pipe" or "qpipe"
 ** action.
 */
 ** variables in the string for a "pipe" or "qpipe"
 ** action.
 */
-
 static void
 glob(int fd)
 {
 static void
 glob(int fd)
 {
@@ -890,25 +924,28 @@ glob(int fd)
        struct stat st;
        struct pair *p;
 
        struct stat st;
        struct pair *p;
 
-       if (globbed++)
+       if (globbed++) {
                return;
                return;
-
-       if ((p = lookup(vars, "sender")))
+       }
+       if ((p = lookup(vars, "sender"))) {
                p->p_value = getcpy(sender);
                p->p_value = getcpy(sender);
-       if ((p = lookup(vars, "address")))
+       }
+       if ((p = lookup(vars, "address"))) {
                p->p_value = getcpy(addr);
                p->p_value = getcpy(addr);
+       }
        if ((p = lookup(vars, "size"))) {
                snprintf(buffer, sizeof(buffer), "%d",
                                fstat(fd, &st) != -1 ? (int) st.st_size : 0);
                p->p_value = getcpy(buffer);
        }
        if ((p = lookup(vars, "size"))) {
                snprintf(buffer, sizeof(buffer), "%d",
                                fstat(fd, &st) != -1 ? (int) st.st_size : 0);
                p->p_value = getcpy(buffer);
        }
-       if ((p = lookup(vars, "info")))
+       if ((p = lookup(vars, "info"))) {
                p->p_value = getcpy(info);
                p->p_value = getcpy(info);
-
+       }
        if (debug) {
        if (debug) {
-               for (p = vars; p->p_name; p++)
+               for (p = vars; p->p_name; p++) {
                        debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
                                        p - vars, p->p_name, trim(p->p_value));
                        debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
                                        p - vars, p->p_name, trim(p->p_value));
+               }
        }
 }
 
        }
 }
 
@@ -917,14 +954,14 @@ glob(int fd)
 ** Find a matching name in a lookup table.  If found,
 ** return the "pairs" entry, else return NULL.
 */
 ** Find a matching name in a lookup table.  If found,
 ** return the "pairs" entry, else return NULL.
 */
-
 static struct pair *
 lookup(struct pair *pairs, char *key)
 {
 static struct pair *
 lookup(struct pair *pairs, char *key)
 {
-       for (; pairs->p_name; pairs++)
-               if (!mh_strcasecmp(pairs->p_name, key))
+       for (; pairs->p_name; pairs++) {
+               if (!mh_strcasecmp(pairs->p_name, key)) {
                        return pairs;
                        return pairs;
-
+               }
+       }
        return NULL;
 }
 
        return NULL;
 }
 
@@ -933,19 +970,18 @@ lookup(struct pair *pairs, char *key)
 ** Check utmp(x) file to see if user is currently
 ** logged in.
 */
 ** Check utmp(x) file to see if user is currently
 ** logged in.
 */
-
 #ifdef HAVE_GETUTENT
 static int
 logged_in(void)
 {
        struct utmp * utp;
 
 #ifdef HAVE_GETUTENT
 static int
 logged_in(void)
 {
        struct utmp * utp;
 
-       if (utmped)
+       if (utmped) {
                return utmped;
                return utmped;
-
+       }
        setutent();
 
        setutent();
 
-       while ((utp = getutent()) != NULL) {
+       while ((utp = getutent())) {
                if (
 #ifdef HAVE_STRUCT_UTMP_UT_TYPE
                                utp->ut_type == USER_PROCESS &&
                if (
 #ifdef HAVE_STRUCT_UTMP_UT_TYPE
                                utp->ut_type == USER_PROCESS &&
@@ -953,8 +989,9 @@ logged_in(void)
                                utp->ut_name[0] != 0 &&
                                strncmp(user, utp->ut_name,
                                sizeof(utp->ut_name)) == 0) {
                                utp->ut_name[0] != 0 &&
                                strncmp(user, utp->ut_name,
                                sizeof(utp->ut_name)) == 0) {
-                       if (debug)
+                       if (debug) {
                                continue;
                                continue;
+                       }
                        endutent();
                        return (utmped = DONE);
                }
                        endutent();
                        return (utmped = DONE);
                }
@@ -970,43 +1007,45 @@ logged_in(void)
        struct utmp ut;
        FILE *uf;
 
        struct utmp ut;
        FILE *uf;
 
-       if (utmped)
+       if (utmped) {
                return utmped;
                return utmped;
-
-       if ((uf = fopen(UTMP_FILE, "r")) == NULL)
+       }
+       if (!(uf = fopen(UTMP_FILE, "r"))) {
                return NOTOK;
                return NOTOK;
-
+       }
        while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
        while (fread((char *) &ut, sizeof(ut), 1, uf) == 1) {
-               if (ut.ut_name[0] != 0 &&
-                               strncmp(user, ut.ut_name, sizeof(ut.ut_name))
-                               == 0) {
-                       if (debug)
+               if (ut.ut_name[0] && strncmp(user, ut.ut_name,
+                               sizeof(ut.ut_name))==0) {
+                       if (debug) {
                                continue;
                                continue;
+                       }
                        fclose(uf);
                        return (utmped = DONE);
                }
        }
                        fclose(uf);
                        return (utmped = DONE);
                }
        }
-
        fclose(uf);
        return (utmped = NOTOK);
 }
 #endif
 
        fclose(uf);
        return (utmped = NOTOK);
 }
 #endif
 
-#define check(t,a,b)  if (t < a || t > b) return -1
-#define cmpar(h1,m1,h2,m2)  if (h1 < h2 || (h1 == h2 && m1 < m2)) return 0
+#define check(t,a,b)  if ((t) < (a) || (t) > (b)) return -1
+#define cmpar(h1,m1,h2,m2)  if ((h1)<(h2) || ((h1)==(h2) && (m1)<(m2))) \
+               return 0
 
 static int
 timely(char *t1, char *t2)
 {
        int t1hours, t1mins, t2hours, t2mins;
 
 
 static int
 timely(char *t1, char *t2)
 {
        int t1hours, t1mins, t2hours, t2mins;
 
-       if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2)
+       if (sscanf(t1, "%d:%d", &t1hours, &t1mins) != 2) {
                return -1;
                return -1;
+       }
        check(t1hours, 0, 23);
        check(t1mins, 0, 59);
 
        check(t1hours, 0, 23);
        check(t1mins, 0, 59);
 
-       if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2)
+       if (sscanf(t2, "%d:%d", &t2hours, &t2mins) != 2) {
                return -1;
                return -1;
+       }
        check(t2hours, 0, 23);
        check(t2mins, 0, 59);
 
        check(t2hours, 0, 23);
        check(t2mins, 0, 59);
 
@@ -1018,125 +1057,82 @@ timely(char *t1, char *t2)
 
 
 /*
 
 
 /*
-** Deliver message by appending to a file.
+** Deliver message by appending to a file, using rcvpack(1).
 */
 */
-
 static int
 usr_file(int fd, char *mailbox)
 {
 static int
 usr_file(int fd, char *mailbox)
 {
-       int md;
-
-       if (verbose)
-               verbose_printf("delivering to file \"%s\"", mailbox);
+       char *vec[3];
 
 
-       if (verbose)
-               verbose_printf(" (mbox style)");
-
-       /* open and lock the file */
-       if ((md = mbox_open(mailbox, pw->pw_uid, pw->pw_gid,
-                       m_gmprot())) == -1) {
-               if (verbose)
-                       adorn("", "unable to open:");
-               return -1;
-       }
-
-       lseek(fd, (off_t) 0, SEEK_SET);
-
-       /* append message to file */
-       if (mbox_copy(md, fd) == -1) {
-               if (verbose)
-                       adorn("", "error writing to:");
-               return -1;
-       }
-
-       /* close and unlock file */
-       if (mbox_close(mailbox, md) == NOTOK) {
-               if (verbose)
-                       adorn("", "error closing:");
-               return -1;
+       if (verbose) {
+               verbose_printf("delivering to file \"%s\" (mbox style)",
+                               mailbox);
        }
        }
+       vec[0] = "rcvpack";
+       vec[1] = mailbox;
+       vec[2] = NULL;
 
 
-       if (verbose)
-               verbose_printf(", success.\n");
-       return 0;
+       return usr_pipe(fd, "rcvpack", "rcvpack", vec, 1);
 }
 
 
 /*
 }
 
 
 /*
-** Deliver message to a nmh folder.
+** Deliver message to a nmh folder, using rcvstore(1).
 */
 */
-
 static int
 usr_folder(int fd, char *string)
 {
 static int
 usr_folder(int fd, char *string)
 {
-       int status;
        char folder[BUFSIZ], *vec[3];
 
        /* get folder name ready */
        char folder[BUFSIZ], *vec[3];
 
        /* get folder name ready */
-       if (*string == '+')
+       if (*string == '+') {
                strncpy(folder, string, sizeof(folder));
                strncpy(folder, string, sizeof(folder));
-       else
+       }else {
                snprintf(folder, sizeof(folder), "+%s", string);
                snprintf(folder, sizeof(folder), "+%s", string);
-
-       if (verbose)
+       }
+       if (verbose) {
                verbose_printf("delivering to folder \"%s\"", folder + 1);
                verbose_printf("delivering to folder \"%s\"", folder + 1);
-
+       }
        vec[0] = "rcvstore";
        vec[1] = folder;
        vec[2] = NULL;
 
        vec[0] = "rcvstore";
        vec[1] = folder;
        vec[2] = NULL;
 
-       /* use rcvstore to put message in folder */
-       status = usr_pipe(fd, "rcvstore", rcvstoreproc, vec, 1);
-
-#if 0
-       /*
-       ** Currently, verbose status messages are handled by usr_pipe().
-       */
-       if (verbose) {
-               if (status == 0)
-                       verbose_printf(", success.\n");
-               else
-                       verbose_printf(", failed.\n");
-       }
-#endif
-
-       return status;
+       return usr_pipe(fd, "rcvstore", rcvstoreproc, vec, 1);
 }
 
 /*
 ** Deliver message to a process.
 */
 }
 
 /*
 ** Deliver message to a process.
 */
-
 static int
 usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
 {
        pid_t child_id;
 static int
 usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
 {
        pid_t child_id;
-       int i, bytes, seconds, status;
+       int bytes, seconds, status;
        struct stat st;
 
        struct stat st;
 
-       if (verbose && !suppress)
+       if (verbose && !suppress) {
                verbose_printf("delivering to pipe \"%s\"", cmd);
                verbose_printf("delivering to pipe \"%s\"", cmd);
-
+       }
        lseek(fd, (off_t) 0, SEEK_SET);
 
        lseek(fd, (off_t) 0, SEEK_SET);
 
-       for (i = 0; (child_id = fork()) == -1 && i < 5; i++)
-               sleep(5);
-
-       switch (child_id) {
+       switch ((child_id = fork())) {
        case -1:
                /* fork error */
        case -1:
                /* fork error */
-               if (verbose)
+               if (verbose) {
                        adorn("fork", "unable to");
                        adorn("fork", "unable to");
+               }
                return -1;
 
        case 0:
                /* child process */
                return -1;
 
        case 0:
                /* child process */
-               if (fd != 0)
+               if (fd != 0) {
                        dup2(fd, 0);
                        dup2(fd, 0);
+               }
                freopen("/dev/null", "w", stdout);
                freopen("/dev/null", "w", stderr);
                freopen("/dev/null", "w", stdout);
                freopen("/dev/null", "w", stderr);
-               if (fd != 3)
+               if (fd != 3) {
                        dup2(fd, 3);
                        dup2(fd, 3);
+               }
                closefds(4);
 
 #ifdef TIOCNOTTY
                closefds(4);
 
 #ifdef TIOCNOTTY
@@ -1159,39 +1155,7 @@ usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
 
        default:
                /* parent process */
 
        default:
                /* parent process */
-               if (!setjmp(myctx)) {
-                       SIGNAL(SIGALRM, alrmser);
-                       bytes = fstat(fd, &st) != -1 ?
-                                       (int) st.st_size : 100;
-
-                       /*
-                       ** amount of time to wait depends on
-                       ** message size
-                       */
-                       if (bytes <= 100) {
-                               /* give at least 5 minutes */
-                               seconds = 300;
-                       } else if (bytes >= 90000) {
-                               /* a half hour is long enough */
-                               seconds = 1800;
-                       } else {
-                               seconds = (bytes / 60) + 300;
-                       }
-                       alarm((unsigned int) seconds);
-                       status = pidwait(child_id, 0);
-                       alarm(0);
-
-                       if (verbose) {
-                               if (status == 0)
-                                       verbose_printf(", success.\n");
-                               else
-                                       if ((status & 0xff00) == 0xff00)
-                                               verbose_printf(", system error\n");
-                                       else
-                                               pidstatus(status, stdout, ", failed");
-                       }
-                       return (status == 0 ? 0 : -1);
-               } else {
+               if (setjmp(myctx)) {
                        /*
                        ** Ruthlessly kill the child and anything
                        ** else in its process group.
                        /*
                        ** Ruthlessly kill the child and anything
                        ** else in its process group.
@@ -1201,6 +1165,33 @@ usr_pipe(int fd, char *cmd, char *pgm, char **vec, int suppress)
                                verbose_printf(", timed-out; terminated\n");
                        return -1;
                }
                                verbose_printf(", timed-out; terminated\n");
                        return -1;
                }
+               SIGNAL(SIGALRM, alrmser);
+               bytes = fstat(fd, &st) != -1 ? (int) st.st_size : 100;
+
+               /* amount of time to wait depends on message size */
+               if (bytes <= 100) {
+                       /* give at least 5 minutes */
+                       seconds = 300;
+               } else if (bytes >= 90000) {
+                       /* a half hour is long enough */
+                       seconds = 1800;
+               } else {
+                       seconds = (bytes / 60) + 300;
+               }
+               alarm((unsigned int) seconds);
+               status = pidwait(child_id, 0);
+               alarm(0);
+
+               if (verbose) {
+                       if (!status) {
+                               verbose_printf(", success.\n");
+                       } else if ((status & 0xff00) == 0xff00) {
+                               verbose_printf(", system error\n");
+                       } else {
+                               pidstatus(status, stdout, ", failed");
+                       }
+               }
+               return (status == 0 ? 0 : -1);
        }
 }
 
        }
 }
 
@@ -1220,7 +1211,6 @@ alrmser(int i)
 ** Get the `sender' from the envelope
 ** information ("From " line).
 */
 ** Get the `sender' from the envelope
 ** information ("From " line).
 */
-
 static void
 get_sender(char *envelope, char **sender)
 {
 static void
 get_sender(char *envelope, char **sender)
 {
@@ -1228,7 +1218,7 @@ get_sender(char *envelope, char **sender)
        unsigned char *cp;
        unsigned char buffer[BUFSIZ];
 
        unsigned char *cp;
        unsigned char buffer[BUFSIZ];
 
-       if (envelope == NULL) {
+       if (!envelope) {
                *sender = getcpy("");
                return;
        }
                *sender = getcpy("");
                return;
        }
@@ -1236,20 +1226,22 @@ get_sender(char *envelope, char **sender)
        i = strlen("From ");
        strncpy(buffer, envelope + i, sizeof(buffer));
        if ((cp = strchr(buffer, '\n'))) {
        i = strlen("From ");
        strncpy(buffer, envelope + i, sizeof(buffer));
        if ((cp = strchr(buffer, '\n'))) {
-               *cp = 0;
+               *cp = '\0';
                cp -= 24;
                cp -= 24;
-               if (cp < buffer)
+               if (cp < buffer) {
                        cp = buffer;
                        cp = buffer;
+               }
        } else {
                cp = buffer;
        }
        } else {
                cp = buffer;
        }
-       *cp = 0;
+       *cp = '\0';
 
        for (cp = buffer + strlen(buffer) - 1; cp >= buffer; cp--)
 
        for (cp = buffer + strlen(buffer) - 1; cp >= buffer; cp--)
-               if (isspace(*cp))
-                       *cp = 0;
-               else
+               if (isspace(*cp)) {
+                       *cp = '\0';
+               } else {
                        break;
                        break;
+               }
        *sender = getcpy(buffer);
 }
 
        *sender = getcpy(buffer);
 }
 
@@ -1259,7 +1251,6 @@ get_sender(char *envelope, char **sender)
 ** While copying, it will do some header processing
 ** including the extraction of the envelope information.
 */
 ** While copying, it will do some header processing
 ** including the extraction of the envelope information.
 */
-
 static int
 copy_message(int qd, char *tmpfil, int fold)
 {
 static int
 copy_message(int qd, char *tmpfil, int fold)
 {
@@ -1274,15 +1265,17 @@ copy_message(int qd, char *tmpfil, int fold)
        strncpy(tmpfil, tfile, BUFSIZ);
 
        if (!fold) {
        strncpy(tmpfil, tfile, BUFSIZ);
 
        if (!fold) {
-               while ((i = read(qd, buffer, sizeof(buffer))) > 0)
+               while ((i = read(qd, buffer, sizeof(buffer))) > 0) {
                        if (write(fd1, buffer, i) != i) {
 you_lose:
                                close(fd1);
                                unlink(tmpfil);
                                return -1;
                        }
                        if (write(fd1, buffer, i) != i) {
 you_lose:
                                close(fd1);
                                unlink(tmpfil);
                                return -1;
                        }
-               if (i == -1)
+               }
+               if (i == -1) {
                        goto you_lose;
                        goto you_lose;
+               }
                lseek(fd1, (off_t) 0, SEEK_SET);
                return fd1;
        }
                lseek(fd1, (off_t) 0, SEEK_SET);
                return fd1;
        }
@@ -1294,7 +1287,7 @@ you_lose:
        }
 
        /* now create a FILE pointer for it */
        }
 
        /* now create a FILE pointer for it */
-       if ((qfp = fdopen(fd2, "r")) == NULL) {
+       if (!(qfp = fdopen(fd2, "r"))) {
                close(fd1);
                close(fd2);
                return -1;
                close(fd1);
                close(fd2);
                return -1;
@@ -1308,7 +1301,7 @@ you_lose:
        }
 
        /* now create a FILE pointer for it */
        }
 
        /* now create a FILE pointer for it */
-       if ((ffp = fdopen(fd2, "r+")) == NULL) {
+       if (!(ffp = fdopen(fd2, "r+"))) {
                close(fd1);
                close(fd2);
                fclose(qfp);
                close(fd1);
                close(fd2);
                fclose(qfp);
@@ -1334,27 +1327,18 @@ you_lose:
                                */
                                envelope = getcpy(buffer);
 
                                */
                                envelope = getcpy(buffer);
 
-#if 0
-                               /*
-                               ** First go ahead and put "From " line
-                               ** in message
-                               */
-                               fputs(buffer, ffp);
-                               if (ferror(ffp))
-                                       goto fputs_error;
-#endif
-
 #ifdef RPATHS
                                /*
                                ** Now create a "Return-Path:" line
                                ** from the "From " line.
                                */
                                hp = cp = strchr(fp = envelope + i, ' ');
 #ifdef RPATHS
                                /*
                                ** Now create a "Return-Path:" line
                                ** from the "From " line.
                                */
                                hp = cp = strchr(fp = envelope + i, ' ');
-                               while ((hp = strchr(++hp, 'r')))
+                               while ((hp = strchr(++hp, 'r'))) {
                                        if (uprf(hp, "remote from")) {
                                                hp = strrchr(hp, ' ');
                                                break;
                                        }
                                        if (uprf(hp, "remote from")) {
                                                hp = strrchr(hp, ' ');
                                                break;
                                        }
+                               }
                                if (hp) {
                                        /*
                                        ** return path for UUCP style
                                if (hp) {
                                        /*
                                        ** return path for UUCP style
@@ -1372,21 +1356,23 @@ you_lose:
 
                                /* Add Return-Path header to message */
                                fputs(buffer, ffp);
 
                                /* Add Return-Path header to message */
                                fputs(buffer, ffp);
-                               if (ferror(ffp))
+                               if (ferror(ffp)) {
                                        goto fputs_error;
                                        goto fputs_error;
+                               }
 #endif
                                /* Put the delivery date in message */
                                fputs(ddate, ffp);
 #endif
                                /* Put the delivery date in message */
                                fputs(ddate, ffp);
-                               if (ferror(ffp))
+                               if (ferror(ffp)) {
                                        goto fputs_error;
                                        goto fputs_error;
-
+                               }
                                continue;
                        }
                }
 
                fputs(buffer, ffp);
                                continue;
                        }
                }
 
                fputs(buffer, ffp);
-               if (ferror(ffp))
+               if (ferror(ffp)) {
                        goto fputs_error;
                        goto fputs_error;
+               }
        }
 
        fclose(ffp);
        }
 
        fclose(ffp);
@@ -1399,7 +1385,6 @@ you_lose:
        lseek(fd1, (off_t) 0, SEEK_SET);
        return fd1;
 
        lseek(fd1, (off_t) 0, SEEK_SET);
        return fd1;
 
-
 fputs_error:
        close(fd1);
        fclose(ffp);
 fputs_error:
        close(fd1);
        fclose(ffp);
@@ -1410,45 +1395,45 @@ fputs_error:
 /*
 ** Trim strings for pretty printing of debugging output
 */
 /*
 ** Trim strings for pretty printing of debugging output
 */
-
 static char *
 trim(char *cp)
 {
        char buffer[BUFSIZ*4];
        unsigned char *bp, *sp;
 
 static char *
 trim(char *cp)
 {
        char buffer[BUFSIZ*4];
        unsigned char *bp, *sp;
 
-       if (cp == NULL)
+       if (!cp) {
                return NULL;
                return NULL;
+       }
 
        /* copy string into temp buffer */
        strncpy(buffer, cp, sizeof(buffer));
        bp = buffer;
 
        /* skip over leading whitespace */
 
        /* copy string into temp buffer */
        strncpy(buffer, cp, sizeof(buffer));
        bp = buffer;
 
        /* skip over leading whitespace */
-       while (isspace(*bp))
+       while (isspace(*bp)) {
                bp++;
                bp++;
-
+       }
        /* start at the end and zap trailing whitespace */
        for (sp = bp + strlen(bp) - 1; sp >= bp; sp--) {
        /* start at the end and zap trailing whitespace */
        for (sp = bp + strlen(bp) - 1; sp >= bp; sp--) {
-               if (isspace(*sp))
-                       *sp = 0;
-               else
+               if (isspace(*sp)) {
+                       *sp = '\0';
+               } else {
                        break;
                        break;
+               }
        }
 
        /* replace remaining whitespace with spaces */
        }
 
        /* replace remaining whitespace with spaces */
-       for (sp = bp; *sp; sp++)
-               if (isspace(*sp))
+       for (sp = bp; *sp; sp++) {
+               if (isspace(*sp)) {
                        *sp = ' ';
                        *sp = ' ';
-
-       /* now return a copy */
+               }
+       }
        return getcpy(bp);
 }
 
 /*
 ** Function for printing `verbose' messages.
 */
        return getcpy(bp);
 }
 
 /*
 ** Function for printing `verbose' messages.
 */
-
 static void
 verbose_printf(char *fmt, ...)
 {
 static void
 verbose_printf(char *fmt, ...)
 {
@@ -1457,8 +1442,7 @@ verbose_printf(char *fmt, ...)
        va_start(ap, fmt);
        vfprintf(stdout, fmt, ap);
        va_end(ap);
        va_start(ap, fmt);
        vfprintf(stdout, fmt, ap);
        va_end(ap);
-
-       fflush(stdout);  /* now flush output */
+       fflush(stdout);
 }
 
 
 }
 
 
@@ -1466,7 +1450,6 @@ verbose_printf(char *fmt, ...)
 ** Function for printing `verbose' delivery
 ** error messages.
 */
 ** Function for printing `verbose' delivery
 ** error messages.
 */
-
 static void
 adorn(char *what, char *fmt, ...)
 {
 static void
 adorn(char *what, char *fmt, ...)
 {
@@ -1482,12 +1465,14 @@ adorn(char *what, char *fmt, ...)
        va_end(ap);
 
        if (what) {
        va_end(ap);
 
        if (what) {
-               if (*what)
+               if (*what) {
                        fprintf(stdout, " %s: ", what);
                        fprintf(stdout, " %s: ", what);
-               if ((s = strerror(eindex)))
+               }
+               if ((s = strerror(eindex))) {
                        fprintf(stdout, "%s", s);
                        fprintf(stdout, "%s", s);
-               else
+               } else {
                        fprintf(stdout, "Error %d", eindex);
                        fprintf(stdout, "Error %d", eindex);
+               }
        }
 
        fputc('\n', stdout);
        }
 
        fputc('\n', stdout);
@@ -1498,7 +1483,6 @@ adorn(char *what, char *fmt, ...)
 /*
 ** Function for printing `debug' messages.
 */
 /*
 ** Function for printing `debug' messages.
 */
-
 static void
 debug_printf(char *fmt, ...)
 {
 static void
 debug_printf(char *fmt, ...)
 {