X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Frcvdist.c;h=7d669109abd1a11a1a47d8fea02186fbaae1996e;hb=676aafb5cca9531170843b28fe4e3ba12c322c50;hp=c4be1b2b70208171aab617c91fb94fc512f6a7fb;hpb=81a21a9a97d8633f6d6231e31fdb6e328d0d3ff2;p=mmh diff --git a/uip/rcvdist.c b/uip/rcvdist.c index c4be1b2..7d66910 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -34,7 +34,7 @@ static char tmpfil[BUFSIZ] = ""; * prototypes */ static void rcvdistout (FILE *, char *, char *); -int done (int); +static void unlink_done (int) NORETURN; int @@ -44,7 +44,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 +95,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); @@ -202,7 +211,7 @@ rcvdistout (FILE *inb, char *form, char *addrs) case FLDPLUS: if ((cptr = wantcomp[CHASH (name)])) do { - if (!strcasecmp (name, cptr->c_name)) { + if (!mh_strcasecmp (name, cptr->c_name)) { char_read += msg_count; if (!cptr->c_text) { cptr->c_text = tmpbuf; @@ -268,8 +277,8 @@ finished: ; } -int -done (int status) +static void +unlink_done (int status) { if (backup[0]) unlink (backup); @@ -279,5 +288,4 @@ done (int status) unlink (tmpfil); exit (status ? RCV_MBX : RCV_MOK); - return 1; /* dead code to satisfy the compiler */ }