Fixed make_bcc_file () to use contents of From: in draft, if draft_from masquerade...
[mmh] / uip / rcvdist.c
index b210696..c4be1b2 100644 (file)
@@ -3,12 +3,18 @@
  * rcvdist.c -- asynchronously redistribute messages
  *
  * $Id$
+ *
+ * This code is Copyright (c) 2002, by the authors of nmh.  See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
  */
 
 #include <h/mh.h>
 #include <h/fmt_scan.h>
 #include <h/rcvmail.h>
-#include <zotnet/tws/tws.h>
+#include <h/tws.h>
+#include <h/mts.h>
+#include <h/utils.h>
 
 static struct swit switches[] = {
 #define        FORMSW       0
@@ -16,7 +22,7 @@ static struct swit switches[] = {
 #define VERSIONSW    1
     { "version", 0 },
 #define        HELPSW       2
-    { "help", 4 },
+    { "help", 0 },
     { NULL, 0 }
 };
 
@@ -28,7 +34,7 @@ static char tmpfil[BUFSIZ] = "";
  * prototypes
  */
 static void rcvdistout (FILE *, char *, char *);
-void done (int);
+int done (int);
 
 
 int
@@ -117,7 +123,8 @@ main (int argc, char **argv)
        default: 
            done (pidXwait(child_id, postproc));
     }
-/* NOTREACHED */
+
+    return 0;  /* dead code to satisfy the compiler */
 }
 
 /* very similar to routine in replsbr.c */
@@ -175,8 +182,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
     *--savecomp = 0;
 
     for (i = ncomps; i--;)
-       if (!(*nxtbuf++ = malloc (SBUFSIZ)))
-           adios (NULL, "unable to allocate component buffer");
+       *nxtbuf++ = mh_xmalloc (SBUFSIZ);
     nxtbuf = compbuffers;
     tmpbuf = *nxtbuf++;
 
@@ -205,13 +211,14 @@ rcvdistout (FILE *inb, char *form, char *addrs)
                            }
                            else {
                                i = strlen (cp = cptr->c_text) - 1;
-                               if (cp[i] == '\n')
+                               if (cp[i] == '\n') {
                                    if (cptr->c_type & CT_ADDR) {
                                        cp[i] = 0;
                                        cp = add (",\n\t", cp);
                                    }
                                    else
                                        cp = add ("\t", cp);
+                               }
                                cptr->c_text = add (tmpbuf, cp);
                            }
                            while (state == FLDPLUS) {
@@ -241,7 +248,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
 finished: ;
 
     i = format_len + char_read + 256;
-    scanl = malloc ((size_t) i + 2);
+    scanl = mh_xmalloc ((size_t) i + 2);
     dat[0] = dat[1] = dat[2] = dat[4] = 0;
     dat[3] = outputlinelen;
     fmt_scan (fmt, scanl, i, dat);
@@ -252,7 +259,7 @@ finished: ;
     fclose (out);
 
     free (scanl);
-    for (nxtbuf = compbuffers, i = ncomps; cptr = *savecomp++; nxtbuf++, i--)
+    for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++); nxtbuf++, i--)
        free (cptr->c_text);
     while (i-- > 0)
         free (*nxtbuf++);
@@ -261,7 +268,7 @@ finished: ;
 }
 
 
-void
+int
 done (int status)
 {
     if (backup[0])
@@ -272,4 +279,5 @@ done (int status)
        unlink (tmpfil);
 
     exit (status ? RCV_MBX : RCV_MOK);
+    return 1;  /* dead code to satisfy the compiler */
 }