-** Filter the messages you are forwarding, into the
-** draft calling the mhlproc, and reading its output
-** from a pipe.
-*/
-
-static void
-mhl_draft (int out, char *digest, int volume, int issue,
- char *file, char *filter, int dashstuff)
-{
- pid_t child_id;
- int i, msgnum, pd[2];
- char *vec[MAXARGS];
- char buf1[BUFSIZ];
- char buf2[BUFSIZ];
-
- if (pipe (pd) == NOTOK)
- adios ("pipe", "unable to create");
-
- vec[0] = r1bindex (mhlproc, '/');
-
- for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
- sleep (5);
- switch (child_id) {
- case NOTOK:
- adios ("fork", "unable to");
-
- case OK:
- close (pd[0]);
- dup2 (pd[1], 1);
- close (pd[1]);
-
- i = 1;
- vec[i++] = "-forwall";
- vec[i++] = "-form";
- vec[i++] = filter;
-
- if (digest) {
- vec[i++] = "-digest";
- vec[i++] = digest;
- vec[i++] = "-issue";
- snprintf (buf1, sizeof(buf1), "%d", issue);
- vec[i++] = buf1;
- vec[i++] = "-volume";
- snprintf (buf2, sizeof(buf2), "%d", volume);
- vec[i++] = buf2;
- }
-
- /*
- ** Are we dashstuffing (quoting) the lines that begin
- ** with `-'. We use the mhl default (don't add any
- ** flag) unless the user has specified a specific flag.
- */
- if (dashstuff > 0)
- vec[i++] = "-dashstuffing";
- else if (dashstuff < 0)
- vec[i++] = "-nodashstuffing";
-
- if (mp->numsel >= MAXARGS - i)
- adios (NULL, "more than %d messages for %s exec",
- MAXARGS - i, vec[0]);
-
- /*
- ** Now add the message names to filter. We can only
- ** handle about 995 messages (because vec is fixed
- ** size), but that should be plenty.
- */
- for (msgnum = mp->lowsel;
- msgnum <= mp->hghsel && i < sizeof(vec) - 1;
- msgnum++)
- if (is_selected (mp, msgnum))
- vec[i++] = getcpy (m_name (msgnum));
- vec[i] = NULL;
-
- execvp (mhlproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (mhlproc);
- _exit (-1);
-
- default:
- close (pd[1]);
- cpydata (pd[0], out, vec[0], file);
- close (pd[0]);
- pidXwait(child_id, mhlproc);
- break;
- }
-}
-
-
-/*
-** Copy the messages into the draft. The messages are
-** not filtered through the mhlproc. Do dashstuffing if
-** necessary.