/*
- * forw.c -- forward a message, or group of messages.
- *
- * This code is Copyright (c) 2002, by the authors of nmh. See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
+** forw.c -- forward a message, or group of messages.
+**
+** This code is Copyright (c) 2002, by the authors of nmh. See the
+** COPYRIGHT file in the root directory of the nmh distribution for
+** complete copyright information.
+*/
#include <h/mh.h>
#include <fcntl.h>
{ "annotate", 0 },
#define NANNOSW 1
{ "noannotate", 0 },
-#define DFOLDSW 2
- { "draftfolder +folder", 0 },
-#define DMSGSW 3
- { "draftmessage msg", 0 },
-#define NDFLDSW 4
- { "nodraftfolder", 0 },
-#define EDITRSW 5
+#define EDITRSW 2
{ "editor editor", 0 },
-#define NEDITSW 6
+#define NEDITSW 3
{ "noedit", 0 },
-#define FILTSW 7
+#define FILTSW 4
{ "filter filterfile", 0 },
-#define FORMSW 8
+#define FORMSW 5
{ "form formfile", 0 },
-#define FRMTSW 9
+#define FRMTSW 6
{ "format", 5 },
-#define NFRMTSW 10
+#define NFRMTSW 7
{ "noformat", 7 },
-#define INPLSW 11
+#define INPLSW 8
{ "inplace", 0 },
-#define NINPLSW 12
+#define NINPLSW 9
{ "noinplace", 0 },
-#define MIMESW 13
+#define MIMESW 10
{ "mime", 0 },
-#define NMIMESW 14
+#define NMIMESW 11
{ "nomime", 0 },
-#define DGSTSW 15
+#define DGSTSW 12
{ "digest list", 0 },
-#define ISSUESW 16
+#define ISSUESW 13
{ "issue number", 0 },
-#define VOLUMSW 17
+#define VOLUMSW 14
{ "volume number", 0 },
-#define WHATSW 18
+#define WHATSW 15
{ "whatnowproc program", 0 },
-#define NWHATSW 19
+#define NWHATSW 16
{ "nowhatnowproc", 0 },
-#define BITSTUFFSW 20
+#define BITSTUFFSW 17
{ "dashstuffing", 0 }, /* interface to mhl */
-#define NBITSTUFFSW 21
+#define NBITSTUFFSW 18
{ "nodashstuffing", 0 },
-#define VERSIONSW 22
+#define VERSIONSW 19
{ "version", 0 },
-#define HELPSW 23
+#define HELPSW 20
{ "help", 0 },
-#define FILESW 24
+#define FILESW 21
{ "file file", 4 }, /* interface from msh */
#ifdef MHE
-#define BILDSW 25
+#define BILDSW 22
{ "build", 5 }, /* interface from mhe */
#endif /* MHE */
{ NULL, 0 }
};
-static struct swit aqrnl[] = {
-#define NOSW 0
- { "quit", 0 },
-#define YESW 1
- { "replace", 0 },
-#define LISTDSW 2
- { "list", 0 },
-#define REFILSW 3
- { "refile +folder", 0 },
-#define NEWSW 4
- { "new", 0 },
- { NULL, 0 }
-};
-
-static struct swit aqrl[] = {
- { "quit", 0 },
- { "replace", 0 },
- { "list", 0 },
- { "refile +folder", 0 },
- { NULL, 0 }
-};
-
static char drft[BUFSIZ];
static char delim3[] =
/*
- * static prototypes
- */
+** 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);
{
int msgp = 0, anot = 0, inplace = 1, mime = 0;
int issue = 0, volume = 0, dashstuff = 0;
- int nedit = 0, nwhat = 0, i, in;
- int out, isdf = 0, msgnum;
- char *cp, *cwd, *maildir, *dfolder = NULL;
- char *dmsg = NULL, *digest = NULL, *ed = NULL;
+ 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 *form = NULL, buf[BUFSIZ], value[10];
char **argp, **arguments, *msgs[MAXARGS];
- struct stat st;
#ifdef MHE
int buildsw = 0;
adios (NULL, "bad argument %s %s", argp[-2], cp);
continue;
- case DFOLDSW:
- if (dfolder)
- adios (NULL, "only one draft folder at a time!");
- if (!(cp = *argp++) || *cp == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- dfolder = path (*cp == '+' || *cp == '@' ? cp + 1 : cp,
- *cp != '@' ? TFOLDER : TSUBCWF);
- continue;
- case DMSGSW:
- if (dmsg)
- adios (NULL, "only one draft message at a time!");
- if (!(dmsg = *argp++) || *dmsg == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- case NDFLDSW:
- dfolder = NULL;
- isdf = NOTOK;
- continue;
-
case BITSTUFFSW:
dashstuff = 1; /* trinary logic */
continue;
if (file && (msgp || folder))
adios (NULL, "can't mix files and folders/msgs");
-try_it_again:
-
#ifdef MHE
strncpy (drft, buildsw ? m_maildir ("draft")
- : m_draft (dfolder, NULL, NOUSE, &isdf), sizeof(drft));
-
- /* Check if a draft already exists */
- if (!buildsw && stat (drft, &st) != NOTOK) {
+ : m_draft("new"), sizeof(drft));
#else
- strncpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf), sizeof(drft));
-
- /* Check if a draft already exists */
- if (stat (drft, &st) != NOTOK) {
+ strncpy (drft, m_draft("new"), sizeof(drft));
#endif /* MHE */
- printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
- for (i = LISTDSW; i != YESW;) {
- if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
- done (1);
- switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
- case NOSW:
- done (0);
- case NEWSW:
- dmsg = NULL;
- goto try_it_again;
- case YESW:
- break;
- case LISTDSW:
- showfile (++argp, drft);
- break;
- case REFILSW:
- if (refile (++argp, drft) == 0)
- i = YESW;
- break;
- default:
- advise (NULL, "say what?");
- break;
- }
- }
- }
if (file) {
/*
- * Forwarding a file.
- */
+ ** Forwarding a file.
+ */
anot = 0; /* don't want to annotate a file */
} else {
/*
- * Forwarding a message.
- */
+ ** Forwarding a message.
+ */
if (!msgp)
msgs[msgp++] = "cur";
if (!folder)
adios (filter, "unable to read");
/*
- * Open form (component) file.
- */
+ ** Open form (component) file.
+ */
if (digest) {
if (issue == 0) {
snprintf (buf, sizeof(buf), IFORMAT, digest);
adios (drft, "unable to create");
/*
- * copy the components into the draft
- */
+ ** copy the components into the draft
+ */
cpydata (in, out, form, drft);
close (in);
close (out);
} else {
/*
- * If filter file is defined, then format the
- * messages into the draft using mhlproc.
- */
+ ** 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)
/*
- * Filter the messages you are forwarding, into the
- * draft calling the mhlproc, and reading its output
- * from a pipe.
- */
+** Filter the messages you are forwarding, into the
+** draft calling the mhlproc, and reading its output
+** from a pipe.
+*/
static void
mhl_draft (int out, char *digest, int volume, int issue,
}
/*
- * 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.
- */
+ ** 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)
MAXARGS - i, vec[0]);
/*
- * Now add the message names to filter. We can only
- * handle about 995 messages (because vec is fixed size),
- * but that should be plenty.
- */
- for (msgnum = mp->lowsel; msgnum <= mp->hghsel && i < sizeof(vec) - 1;
- msgnum++)
+ ** Now add the message names to filter. We can only
+ ** handle about 995 messages (because vec is fixed
+ ** size), but that should be plenty.
+ */
+ for (msgnum = mp->lowsel;
+ msgnum <= mp->hghsel && i < sizeof(vec) - 1;
+ msgnum++)
if (is_selected (mp, msgnum))
vec[i++] = getcpy (m_name (msgnum));
vec[i] = NULL;
/*
- * Copy the messages into the draft. The messages are
- * not filtered through the mhlproc. Do dashstuffing if
- * necessary.
- */
+** Copy the messages into the draft. The messages are
+** 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)
+copy_draft (int out, char *digest, char *file, int volume, int issue,
+ int dashstuff)
{
int fd,i, msgcnt, msgnum;
int len, buflen;
}
/*
- * Copy the message. Add RFC934 quoting (dashstuffing)
- * unless given the -nodashstuffing flag.
- */
+ ** Copy the message. Add RFC934 quoting (dashstuffing)
+ ** unless given the -nodashstuffing flag.
+ */
if (dashstuff >= 0)
cpydgst (fd, out, msgnam, file);
else
/*
- * Create a mhbuild composition file for forwarding message.
- */
+** Create a mhbuild composition file for forwarding message.
+*/
static void
copy_mime_draft (int out)