for (state = FLD;;) {
state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
switch (state) {
- case FLD:
- case FLDPLUS:
- /*
- ** if we're interested in this component,
- ** save a pointer to the component text,
- ** then start using our next free buffer
- ** as the component temp buffer (buffer
- ** switching saves an extra copy of the
- ** component text).
- */
- if ((cptr = wantcomp[CHASH(name)]))
- do {
- if (!mh_strcasecmp(name, cptr->c_name)) {
- char_read += msg_count;
- if (! cptr->c_text) {
- i = strlen(cptr->c_text = tmpbuf) - 1;
- if (tmpbuf[i] == '\n')
- tmpbuf[i] = '\0';
- *--savecomp = cptr;
- tmpbuf = *nxtbuf++;
- } else {
- i = strlen(cp = cptr->c_text) - 1;
- if (cp[i] == '\n') {
- if (cptr->c_type & CT_ADDR) {
- cp[i] = '\0';
- cp = add(",\n\t", cp);
- } else {
- cp = add("\t", cp);
- }
+ case FLD:
+ case FLDPLUS:
+ /*
+ ** if we're interested in this component, save
+ ** a pointer to the component text, then start
+ ** using our next free buffer as the component
+ ** temp buffer (buffer switching saves an extra
+ ** copy of the component text).
+ */
+ if ((cptr = wantcomp[CHASH(name)]))
+ do {
+ if (!mh_strcasecmp(name, cptr->c_name)) {
+ char_read += msg_count;
+ if (! cptr->c_text) {
+ i = strlen(cptr->c_text = tmpbuf) - 1;
+ if (tmpbuf[i] == '\n')
+ tmpbuf[i] = '\0';
+ *--savecomp = cptr;
+ tmpbuf = *nxtbuf++;
+ } else {
+ i = strlen(cp = cptr->c_text) - 1;
+ 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) {
- state = m_getfld(state, name, tmpbuf,
- SBUFSIZ, inb);
- cptr->c_text = add(tmpbuf, cptr->c_text);
- char_read += msg_count;
}
- break;
+ cptr->c_text = add(tmpbuf, cp);
}
- } while ((cptr = cptr->c_next));
+ while (state == FLDPLUS) {
+ state = m_getfld(state, name, tmpbuf,
+ SBUFSIZ, inb);
+ cptr->c_text = add(tmpbuf, cptr->c_text);
+ char_read += msg_count;
+ }
+ break;
+ }
+ } while ((cptr = cptr->c_next));
- while (state == FLDPLUS)
- state = m_getfld(state, name, tmpbuf, SBUFSIZ, inb);
- break;
+ while (state == FLDPLUS)
+ state = m_getfld(state, name, tmpbuf,
+ SBUFSIZ, inb);
+ break;
- case LENERR:
- case FMTERR:
- case BODY:
- case FILEEOF:
- goto finished;
+ case LENERR:
+ case FMTERR:
+ case BODY:
+ case FILEEOF:
+ goto finished;
- default:
- adios(NULL, "m_getfld() returned %d", state);
+ default:
+ adios(NULL, "m_getfld() returned %d", state);
}
}
fputs( badaddrs, out);
}
- /*
- ** Check if we should filter the message
- ** or add mhbuild directives
- */
+ /* Check if we should filter the message */
if (filter) {
fflush(out);
if (ferror(out))
adios(drft, "error writing");
replfilter(inb, out, filter);
- } else if (mime && mp) {
- fprintf(out, "#forw [original message] +%s %s\n",
- mp->foldpath, m_name(mp->lowsel));
}
fflush(out);
adios(drft, "error writing");
fclose(out);
+ /* if we want mime, then add an attachment header */
+ if (!filter && mime && mp) {
+ char buffer[BUFSIZ];
+
+ snprintf(buffer, sizeof buffer, "+%s %s",
+ mp->foldpath, m_name(mp->lowsel));
+ annotate(drft, attach_hdr, buffer, 1, 0, -2, 1);
+ }
+
/* return dynamically allocated buffers */
free(scanl);
for (nxtbuf = compbuffers, i = ncomps; (cptr = *savecomp++);
rewind(in);
lseek(fileno(in), (off_t) 0, SEEK_SET);
- switch (pid = vfork()) {
- case NOTOK:
- adios("fork", "unable to");
-
- case OK:
- dup2(fileno(in), fileno(stdin));
- dup2(fileno(out), fileno(stdout));
- closefds(3);
-
- execlp(mhlproc, mhl, "-form", filter, "-noclear",
- NULL);
- errstr = strerror(errno);
- write(2, "unable to exec ", 15);
- write(2, mhlproc, strlen(mhlproc));
- write(2, ": ", 2);
- write(2, errstr, strlen(errstr));
- write(2, "\n", 1);
- _exit(-1);
-
- default:
- if (pidXwait(pid, mhl))
- done(1);
- fseek(out, 0L, SEEK_END);
- break;
+ switch (pid = fork()) {
+ case NOTOK:
+ adios("fork", "unable to");
+
+ case OK:
+ dup2(fileno(in), fileno(stdin));
+ dup2(fileno(out), fileno(stdout));
+ closefds(3);
+
+ execlp(mhlproc, mhl, "-form", filter, "-noclear", NULL);
+ errstr = strerror(errno);
+ write(2, "unable to exec ", 15);
+ write(2, mhlproc, strlen(mhlproc));
+ write(2, ": ", 2);
+ write(2, errstr, strlen(errstr));
+ write(2, "\n", 1);
+ _exit(-1);
+
+ default:
+ if (pidXwait(pid, mhl))
+ done(1);
+ fseek(out, 0L, SEEK_END);
+ break;
}
}