X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fforw.c;h=c3474c5f4e5b8bd763f6d1a1722ee65c21f5b291;hb=8d102acadc29635b951f7e113c49d9ea686c7b2d;hp=9cdb793f10004f602661ebab9a27c568f56b5631;hpb=4d4f3e6367922ac4237d87ccfb070dbbcb6ff6be;p=mmh diff --git a/uip/forw.c b/uip/forw.c index 9cdb793..c3474c5 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -33,33 +33,27 @@ static struct swit switches[] = { { "format", 5 }, #define NFRMTSW 7 { "noformat", 7 }, -#define INPLSW 8 - { "inplace", 0 }, -#define NINPLSW 9 - { "noinplace", 0 }, -#define MIMESW 10 +#define MIMESW 8 { "mime", 0 }, -#define NMIMESW 11 +#define NMIMESW 9 { "nomime", 0 }, -#define DGSTSW 12 +#define DGSTSW 10 { "digest list", 0 }, -#define ISSUESW 13 +#define ISSUESW 11 { "issue number", 0 }, -#define VOLUMSW 14 +#define VOLUMSW 12 { "volume number", 0 }, -#define WHATSW 15 +#define WHATSW 13 { "whatnowproc program", 0 }, -#define NWHATSW 16 +#define NWHATSW 14 { "nowhatnowproc", 0 }, -#define VERSIONSW 17 +#define VERSIONSW 15 { "version", 0 }, -#define HELPSW 18 +#define HELPSW 16 { "help", 0 }, -#define FILESW 19 - { "file file", 4 }, /* interface from msh */ #ifdef MHE -#define BILDSW 22 +#define BILDSW 17 { "build", 5 }, /* interface from mhe */ #endif /* MHE */ @@ -88,13 +82,13 @@ static int build_form(char *, char *, int, int); int main(int argc, char **argv) { - int msgp = 0, anot = 0, inplace = 1, mime = 0; + int msgp = 0, anot = 0, mime = 0; int issue = 0, volume = 0; int nedit = 0, nwhat = 0, in; int out, msgnum; char *cp, *cwd, *maildir; char *digest = NULL, *ed = NULL; - char *file = NULL, *filter = NULL, *folder = NULL; + char *filter = NULL, *folder = NULL; char *form = NULL, buf[BUFSIZ], value[10]; char **argp, **arguments, *msgs[MAXARGS]; @@ -162,14 +156,6 @@ main(int argc, char **argv) nwhat++; continue; - case FILESW: - if (file) - adios(NULL, "only one file at a time!"); - if (!(cp = *argp++) || *cp == '-') - adios(NULL, "missing argument to %s", - argp[-2]); - file = getcpy(expanddir(cp)); - continue; case FILTSW: if (!(cp = *argp++) || *cp == '-') adios(NULL, "missing argument to %s", @@ -190,13 +176,6 @@ main(int argc, char **argv) filter = NULL; continue; - case INPLSW: - inplace++; - continue; - case NINPLSW: - inplace = 0; - continue; - case MIMESW: mime++; filter = NULL; @@ -241,9 +220,6 @@ main(int argc, char **argv) cwd = getcpy(pwd()); - if (file && (msgp || folder)) - adios(NULL, "can't mix files and folders/msgs"); - #ifdef MHE strncpy(drft, buildsw ? toabsdir("draft") : m_draft(seq_beyond), sizeof(drft)); @@ -251,45 +227,36 @@ main(int argc, char **argv) strncpy(drft, m_draft(seq_beyond), sizeof(drft)); #endif /* MHE */ - if (file) { - /* - ** Forwarding a file. - */ - anot = 0; /* don't want to annotate a file */ - } else { - /* - ** Forwarding a message. - */ - if (!msgp) - msgs[msgp++] = seq_cur; - if (!folder) - folder = getcurfol(); - maildir = toabsdir(folder); - - if (chdir(maildir) == NOTOK) - adios(maildir, "unable to change directory to"); - - /* read folder and create message structure */ - if (!(mp = folder_read(folder))) - adios(NULL, "unable to read folder %s", folder); - - /* check for empty folder */ - if (mp->nummsg == 0) - adios(NULL, "no messages in %s", folder); - - /* parse all the message ranges/sequences and set SELECTED */ - for (msgnum = 0; msgnum < msgp; msgnum++) - if (!m_convert(mp, msgs[msgnum])) - done(1); - seq_setprev(mp); /* set the previous sequence */ - } + /* + ** Forwarding a message. + */ + if (!msgp) + msgs[msgp++] = seq_cur; + if (!folder) + folder = getcurfol(); + maildir = toabsdir(folder); + + if (chdir(maildir) == NOTOK) + adios(maildir, "unable to change directory to"); + + /* read folder and create message structure */ + if (!(mp = folder_read(folder))) + adios(NULL, "unable to read folder %s", folder); + + /* check for empty folder */ + if (mp->nummsg == 0) + adios(NULL, "no messages in %s", folder); + + /* parse all the message ranges/sequences and set SELECTED */ + for (msgnum = 0; msgnum < msgp; msgnum++) + if (!m_convert(mp, msgs[msgnum])) + done(1); + seq_setprev(mp); /* set the previous sequence */ if (filter && access(filter, R_OK) == NOTOK) adios(filter, "unable to read"); - /* - ** Open form (component) file. - */ + /* Open form (component) file. */ if (digest) { if (issue == 0) { snprintf(buf, sizeof(buf), IFORMAT, digest); @@ -318,48 +285,39 @@ main(int argc, char **argv) cpydata(in, out, form, drft); close(in); - if (file) { - /* just copy the file into the draft */ - if ((in = open(file, O_RDONLY)) == NOTOK) - adios(file, "unable to open"); - cpydata(in, out, file, drft); - close(in); + /* + ** If filter file is defined, then format the + ** messages into the draft using mhlproc. + */ + if (filter) { + mhl_draft(out, digest, volume, issue, drft, filter); close(out); + } else if (mime) { + close(out); + add_forw_hdr(drft); } else { - /* - ** If filter file is defined, then format the - ** messages into the draft using mhlproc. - */ - 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); - snprintf(value, sizeof(value), "%d", issue); - context_replace(buf, getcpy(value)); - snprintf(buf, sizeof(buf), VFORMAT, digest); - snprintf(value, sizeof(value), "%d", volume); - context_replace(buf, getcpy(value)); - } + copy_draft(out, digest, drft, volume, issue); + close(out); + } - context_replace(curfolder, folder); /* update current folder */ - seq_setcur(mp, mp->lowsel); /* update current message */ - seq_save(mp); /* synchronize sequences */ - context_save(); /* save the context file */ + if (digest) { + snprintf(buf, sizeof(buf), IFORMAT, digest); + snprintf(value, sizeof(value), "%d", issue); + context_replace(buf, getcpy(value)); + snprintf(buf, sizeof(buf), VFORMAT, digest); + snprintf(value, sizeof(value), "%d", volume); + context_replace(buf, getcpy(value)); } + context_replace(curfolder, folder); /* update current folder */ + seq_setcur(mp, mp->lowsel); /* update current message */ + seq_save(mp); /* synchronize sequences */ + context_save(); /* save the context file */ + if (nwhat) done(0); what_now(ed, nedit, NOUSE, drft, NULL, 0, mp, - anot ? "Forwarded" : NULL, inplace, cwd); + anot ? "Forwarded" : NULL, cwd); done(1); return 1; } @@ -542,7 +500,7 @@ add_forw_hdr(char *draft) strncat(buffer, m_name(msgnum), sizeof(buffer)-strlen(buffer)-1); } - annotate(draft, attach_hdr, buffer, 1, 0, -2, 1); + annotate(draft, attach_hdr, buffer, 0, -2, 1); }