X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Frcvdist.c;h=9038d5ffbda033f38d318bd44dc3fcae6efca99a;hp=e8815653e7713170d3d4a1c15dd3c22dfad8076d;hb=5dd6771b28c257af405d7248639ed0e3bcdce38b;hpb=d2f12554a254e814dcdafb3828fc0d9936154eef diff --git a/uip/rcvdist.c b/uip/rcvdist.c index e881565..9038d5f 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -2,8 +2,6 @@ /* * 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. @@ -34,7 +32,7 @@ static char tmpfil[BUFSIZ] = ""; * prototypes */ static void rcvdistout (FILE *, char *, char *); -int done (int); +static void unlink_done (int) NORETURN; int @@ -44,7 +42,10 @@ main (int argc, char **argv) int i, vecp = 1; char *addrs = NULL, *cp, *form = NULL, buf[BUFSIZ]; char **argp, **arguments, *vec[MAXARGS]; - register FILE *fp; + FILE *fp; + char *tfile = NULL; + + done=unlink_done; #ifdef LOCALE setlocale(LC_ALL, ""); @@ -92,12 +93,18 @@ main (int argc, char **argv) invo_name); umask (~m_gmprot ()); - strncpy (tmpfil, m_tmpfil (invo_name), sizeof(tmpfil)); - if ((fp = fopen (tmpfil, "w+")) == NULL) - adios (tmpfil, "unable to create"); + + tfile = m_mktemp2(NULL, invo_name, NULL, &fp); + if (tfile == NULL) adios("rcvdist", "unable to create temporary file"); + strncpy (tmpfil, tfile, sizeof(tmpfil)); + cpydata (fileno (stdin), fileno (fp), "message", tmpfil); fseek (fp, 0L, SEEK_SET); - strncpy (drft, m_tmpfil (invo_name), sizeof(drft)); + + tfile = m_mktemp2(NULL, invo_name, NULL, NULL); + if (tfile == NULL) adios("forw", "unable to create temporary file"); + strncpy (drft, tfile, sizeof(tmpfil)); + rcvdistout (fp, form, addrs); fclose (fp); @@ -268,8 +275,8 @@ finished: ; } -int -done (int status) +static void +unlink_done (int status) { if (backup[0]) unlink (backup); @@ -279,5 +286,4 @@ done (int status) unlink (tmpfil); exit (status ? RCV_MBX : RCV_MOK); - return 1; /* dead code to satisfy the compiler */ }