-static void
-make_bcc_file (void)
-{
- pid_t child_id;
- int fd, i, status;
- char *vec[6];
- FILE * in, *out;
-
-#ifdef HAVE_MKSTEMP
- fd = mkstemp(bccfil);
- if (fd == -1 || (out = fdopen(fd, "w")) == NULL)
- adios (bccfil, "unable to create");
-#else
- mktemp (bccfil);
- if ((out = fopen (bccfil, "w")) == NULL)
- adios (bccfil, "unable to create");
-#endif
- chmod (bccfil, 0600);
-
- fprintf (out, "Date: %s\n", dtimenow (0));
- if (msgflags & MFRM) {
- /* There was already a From: in the draft. Don't add one. */
- if (!draft_from_masquerading)
- /*
- ** mts.conf didn't contain "masquerade:[...]draft_from[...]"
- ** so we'll reveal the user's actual account@thismachine
- ** address in a Sender: header (and use it as the envelope
- ** From: later).
- */
- fprintf (out, "Sender: %s\n", from);
- } else
- /* Construct a From: header. */
- fprintf (out, "From: %s\n", signature);
- if (subject)
- fprintf (out, "Subject: %s", subject);
- fprintf (out, "BCC:\n\n------- Blind-Carbon-Copy\n\n");
- fflush (out);
-
- if (filter == NULL) {
- if ((fd = open (tmpfil, O_RDONLY)) == NOTOK)
- adios (NULL, "unable to re-open");
- cpydgst (fd, fileno (out), tmpfil, bccfil);
- close (fd);
- } else {
- vec[0] = r1bindex (mhlproc, '/');
-
- for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
- sleep (5);
- switch (child_id) {
- case NOTOK:
- adios ("vfork", "unable to");
-
- case OK:
- dup2 (fileno (out), 1);
-
- i = 1;
- vec[i++] = "-forward";
- vec[i++] = "-form";
- vec[i++] = filter;
- vec[i++] = tmpfil;
- vec[i] = NULL;
-
- execvp (mhlproc, vec);
- adios (mhlproc, "unable to exec");
-
- default:
- if (status = pidwait(child_id, OK))
- admonish (NULL, "%s lost (status=0%o)",
- vec[0], status);
- break;
+ if (strlen(str)+strlen(fccs) > sizeof fccs /2) {
+ adios(EX_DATAERR, NULL, "Too much Fcc data");
+ }
+ /* todo: better have three states: SEPARATOR, PLUS, WORD */
+ for (cp=pp=str; *cp; cp++) {
+ switch (*cp) {
+ case ' ':
+ case '\t':
+ case '\n':
+ case ',':
+ if (state != 0) {
+ state = 0;
+ *cp = '\0';
+ if (*pp=='+' || *pp=='@') {
+ strcat(fccs, " ");
+ } else {
+ strcat(fccs, " +");
+ }
+ strcat(fccs, pp);
+ }
+ break;
+ default:
+ if (state == 0) {
+ state = 1;
+ pp = cp;
+ }
+ break;