X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fforw.c;h=9cdb793f10004f602661ebab9a27c568f56b5631;hb=a4605f68e8ff04d4539e402a6fb00ff188944e1c;hp=8dc26b792f0df28df8862340b4ae9a10be8cfad6;hpb=3cc8ed080f6e741b8df04a3ebe764c659e75cb38;p=mmh diff --git a/uip/forw.c b/uip/forw.c index 8dc26b7..9cdb793 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -51,15 +51,11 @@ static struct swit switches[] = { { "whatnowproc program", 0 }, #define NWHATSW 16 { "nowhatnowproc", 0 }, -#define BITSTUFFSW 17 - { "dashstuffing", 0 }, /* interface to mhl */ -#define NBITSTUFFSW 18 - { "nodashstuffing", 0 }, -#define VERSIONSW 19 +#define VERSIONSW 17 { "version", 0 }, -#define HELPSW 20 +#define HELPSW 18 { "help", 0 }, -#define FILESW 21 +#define FILESW 19 { "file file", 4 }, /* interface from msh */ #ifdef MHE @@ -83,9 +79,9 @@ static struct msgs *mp = NULL; /* used a lot */ /* ** static prototypes */ -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 mhl_draft(int, char *, int, int, char *, char *); +static void copy_draft(int, char *, char *, int, int); +static void add_forw_hdr(char *); static int build_form(char *, char *, int, int); @@ -93,7 +89,7 @@ int main(int argc, char **argv) { int msgp = 0, anot = 0, inplace = 1, mime = 0; - int issue = 0, volume = 0, dashstuff = 0; + int issue = 0, volume = 0; int nedit = 0, nwhat = 0, in; int out, msgnum; char *cp, *cwd, *maildir; @@ -231,13 +227,6 @@ main(int argc, char **argv) adios(NULL, "bad argument %s %s", argp[-2], cp); continue; - - case BITSTUFFSW: - dashstuff = 1; /* trinary logic */ - continue; - case NBITSTUFFSW: - dashstuff = -1; /* trinary logic */ - continue; } } if (*cp == '+' || *cp == '@') { @@ -341,15 +330,16 @@ main(int argc, char **argv) ** If filter file is defined, then format the ** messages into the draft using mhlproc. */ - if (filter) - mhl_draft(out, digest, volume, issue, drft, filter, - dashstuff); - else if (mime) - copy_mime_draft(out); - else - copy_draft(out, digest, drft, volume, issue, - dashstuff); - close(out); + if (filter) { + mhl_draft(out, digest, volume, issue, drft, filter); + close(out); + } else if (mime) { + close(out); + add_forw_hdr(drft); + } else { + copy_draft(out, digest, drft, volume, issue); + close(out); + } if (digest) { snprintf(buf, sizeof(buf), IFORMAT, digest); @@ -380,10 +370,9 @@ main(int argc, char **argv) ** 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) + char *file, char *filter) { pid_t child_id; int i, msgnum, pd[2]; @@ -423,16 +412,6 @@ mhl_draft(int out, char *digest, int volume, int issue, 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]); @@ -466,13 +445,10 @@ mhl_draft(int out, char *digest, int volume, int issue, /* ** Copy the messages into the draft. The messages are -** not filtered through the mhlproc. Do dashstuffing if -** necessary. +** not filtered through the mhlproc. Do dashstuffing. */ - static void -copy_draft(int out, char *digest, char *file, int volume, int issue, - int dashstuff) +copy_draft(int out, char *digest, char *file, int volume, int issue) { int fd,i, msgcnt, msgnum; int len, buflen; @@ -516,12 +492,8 @@ copy_draft(int out, char *digest, char *file, int volume, int issue, /* ** Copy the message. Add RFC934 quoting (dashstuffing) - ** unless given the -nodashstuffing flag. */ - if (dashstuff >= 0) - cpydgst(fd, out, msgnam, file); - else - cpydata(fd, out, msgnam, file); + cpydgst(fd, out, msgnam, file); close(fd); msgcnt++; @@ -552,25 +524,25 @@ copy_draft(int out, char *digest, char *file, int volume, int issue, /* -** 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); }