*/
static void mhl_draft(int, char *, int, int, char *, char *, int);
static void copy_draft(int, char *, char *, int, int, int);
-static void copy_mime_draft(int);
+static void add_forw_hdr(char *);
static int build_form(char *, char *, int, int);
** If filter file is defined, then format the
** messages into the draft using mhlproc.
*/
- if (filter)
+ if (filter) {
mhl_draft(out, digest, volume, issue, drft, filter,
dashstuff);
- else if (mime)
- copy_mime_draft(out);
- else
+ close(out);
+ } else if (mime) {
+ close(out);
+ add_forw_hdr(drft);
+ } else {
copy_draft(out, digest, drft, volume, issue,
dashstuff);
- close(out);
+ close(out);
+ }
if (digest) {
snprintf(buf, sizeof(buf), IFORMAT, digest);
** 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)
** not filtered through the mhlproc. Do dashstuffing if
** necessary.
*/
-
static void
copy_draft(int out, char *digest, char *file, int volume, int issue,
int dashstuff)
/*
-** Create a mhbuild composition file for forwarding message.
+** Create an attachment header for the to be forward messages.
*/
-
static void
-copy_mime_draft(int out)
+add_forw_hdr(char *draft)
{
int msgnum;
char buffer[BUFSIZ];
- snprintf(buffer, sizeof(buffer), "#forw [forwarded message%s] +%s",
- mp->numsel == 1 ? "" : "s", mp->foldpath);
- write(out, buffer, strlen(buffer));
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++)
- if (is_selected(mp, msgnum)) {
- snprintf(buffer, sizeof(buffer), " %s",
- m_name(msgnum));
- write(out, buffer, strlen(buffer));
+ snprintf(buffer, sizeof(buffer), "+%s", mp->foldpath);
+ for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
+ if (!is_selected(mp, msgnum)) {
+ continue;
}
- write(out, "\n", 1);
+ /* TODO: improve the code */
+ strncat(buffer, " ", sizeof(buffer)-strlen(buffer)-1);
+ strncat(buffer, m_name(msgnum),
+ sizeof(buffer)-strlen(buffer)-1);
+ }
+ annotate(draft, attach_hdr, buffer, 1, 0, -2, 1);
}
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++);
int length; /* length of attachment header field name */
char *p; /* miscellaneous string pointer */
- /*
- ** Open up the draft file.
- */
-
+ /* Open up the draft file. */
if ((draft_file = fopen(draft_file_name, "r")) == (FILE *)0)
adios(NULL, "can't open draft file `%s'.",
draft_file_name);
** Allocate a buffer to hold the header components as they're read in.
** This buffer might need to be quite large, so we grow it as needed.
*/
-
field = (char *)mh_xmalloc(field_size = 256);
/*
** because we're done. Read to the end of the headers even if
** we have no attachments.
*/
-
length = strlen(attach_hdr);
has_attachment = 0;
** Check if body contains at least one non-blank (= not empty)
** and if it contains any non-ASCII chars (= need MIME).
*/
-
has_body = 0;
non_ascii = 0;
while (get_line() != EOF && *field != '\0' && *field != '-') {
if (strncasecmp(field, attach_hdr, length) == 0 &&
field[length] == ':') {
- for (p = field + length + 1; *p == ' ' || *p == '\t';
- p++)
- ;
- make_mime_composition_file_entry(p);
+ for (p = field+length+1; *p==' ' || *p=='\t'; p++) {
+ continue;
+ }
+ if (*p == '+') {
+ /* forwarded message */
+ fprintf(composition_file, "#forw [forwarded message(s)] %s\n", p);
+ } else {
+ make_mime_composition_file_entry(p);
+ }
}
}