]> diplodocus.org Git - nmh/blobdiff - uip/rcvdist.c
Fixed extra and missing trailing commas in SEE ALSO sections of man pages.
[nmh] / uip / rcvdist.c
index 29b341cadca3835d6222e87ec2e48ceb646c5c8e..a123f8e9cb1d75ed5b9e69fa25075e4507b7543d 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * rcvdist.c -- asynchronously redistribute messages
+/* rcvdist.c -- asynchronously redistribute messages
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
@@ -13,6 +11,7 @@
 #include <h/tws.h>
 #include <h/mts.h>
 #include <h/utils.h>
+#include "../sbr/m_mktemp.h"
 
 #define RCVDIST_SWITCHES \
     X("form formfile", 4, FORMSW) \
@@ -89,7 +88,7 @@ main (int argc, char **argv)
                    continue;
            }
        }
-       addrs = addrs ? add (cp, add (", ", addrs)) : getcpy (cp);
+       addrs = addrs ? add (cp, add (", ", addrs)) : mh_xstrdup(cp);
     }
 
     if (addrs == NULL)
@@ -129,7 +128,8 @@ main (int argc, char **argv)
        sleep (5);
     switch (child_id) {
        case NOTOK: 
-           admonish (NULL, "unable to fork");/* fall */
+           inform("unable to fork, continuing...");
+           /* FALLTHRU */
        case OK: 
            execvp (program, vec);
            fprintf (stderr, "unable to exec ");
@@ -145,8 +145,6 @@ main (int argc, char **argv)
 
 /* very similar to routine in replsbr.c */
 
-#define        SBUFSIZ 256
-
 static int outputlinelen = OUTPUTLINELEN;
 
 static struct format *fmt;
@@ -173,13 +171,13 @@ static char *addrcomps[] = {
 static void
 rcvdistout (FILE *inb, char *form, char *addrs)
 {
-    register int char_read = 0, format_len, i, state;
-    register char **ap;
-    char *cp, name[NAMESZ], tmpbuf[SBUFSIZ];
+    int char_read = 0, format_len, i, state;
+    char **ap;
+    char *cp, name[NAMESZ], tmpbuf[NMH_BUFSIZ];
     charstring_t scanl;
-    register struct comp *cptr;
+    struct comp *cptr;
     FILE *out;
-    m_getfld_state_t gstate = 0;
+    m_getfld_state_t gstate;
 
     if (!(out = fopen (drft, "w")))
        adios (drft, "unable to create");
@@ -199,25 +197,26 @@ rcvdistout (FILE *inb, char *form, char *addrs)
     if (cptr)
        cptr->c_text = addrs;
 
+    gstate = m_getfld_state_init(inb);
     for (;;) {
-       int msg_count = SBUFSIZ;
-       switch (state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb)) {
+       int msg_count = sizeof tmpbuf;
+       switch (state = m_getfld2(&gstate, name, tmpbuf, &msg_count)) {
            case FLD: 
            case FLDPLUS: 
                i = fmt_addcomptext(name, tmpbuf);
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
-                       msg_count = SBUFSIZ;
-                       state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
+                       msg_count = sizeof tmpbuf;
+                       state = m_getfld2(&gstate, name, tmpbuf, &msg_count);
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
                }
 
                while (state == FLDPLUS) {
-                   msg_count = SBUFSIZ;
-                   state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
+                   msg_count = sizeof tmpbuf;
+                   state = m_getfld2(&gstate, name, tmpbuf, &msg_count);
                }
                break;
 
@@ -228,7 +227,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
                goto finished;
 
            default: 
-               adios (NULL, "m_getfld() returned %d", state);
+               adios (NULL, "m_getfld2() returned %d", state);
        }
     }
 finished: ;
@@ -250,7 +249,7 @@ finished: ;
 }
 
 
-static void
+static void NORETURN
 unlink_done (int status)
 {
     if (backup[0])