#include <h/utils.h>
static struct swit whatnowswitches[] = {
-#define DFOLDSW 0
- { "draftfolder +folder", 0 },
-#define DMSGSW 1
- { "draftmessage msg", 0 },
-#define NDFLDSW 2
- { "nodraftfolder", 0 },
-#define EDITRSW 3
+#define EDITRSW 0
{ "editor editor", 0 },
-#define NEDITSW 4
+#define NEDITSW 1
{ "noedit", 0 },
-#define PRMPTSW 5
+#define PRMPTSW 2
{ "prompt string", 4 },
-#define VERSIONSW 6
+#define VERSIONSW 3
{ "version", 0 },
-#define HELPSW 7
+#define HELPSW 4
{ "help", 0 },
-#define ATTACHSW 8
+#define ATTACHSW 5
{ "attach header-field-name", 0 },
{ NULL, 0 }
};
{ "send [<switches>]", 0 },
#define PUSHSW 6
{ "push [<switches>]", 0 },
-#define WHOMSW 7
- { "whom [<switches>]", 0 },
-#define QUITSW 8
+#define QUITSW 7
{ "quit [-delete]", 0 },
-#define DELETESW 9
+#define DELETESW 8
{ "delete", 0 },
-#define CDCMDSW 10
+#define CDCMDSW 9
{ "cd [directory]", 0 },
-#define PWDCMDSW 11
+#define PWDCMDSW 10
{ "pwd", 0 },
-#define LSCMDSW 12
+#define LSCMDSW 11
{ "ls", 0 },
-#define ATTACHCMDSW 13
+#define ATTACHCMDSW 12
{ "attach", 0 },
-#define DETACHCMDSW 14
+#define DETACHCMDSW 13
{ "detach [-n]", 2 },
-#define ALISTCMDSW 15
+#define ALISTCMDSW 14
{ "alist [-ln] ", 2 },
{ NULL, 0 }
};
static void sendit (char *, char **, char *, int);
static int buildfile (char **, char *);
static int check_draft (char *);
-static int whomfile (char **, char *);
static int removefile (char *);
static void writelscmd(char *, int, char **);
static void writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp);
int
WhatNow (int argc, char **argv)
{
- int isdf = 0, nedit = 0, use = 0;
- char *cp, *dfolder = NULL, *dmsg = NULL;
+ int nedit = 0, use = 0;
+ char *cp;
char *ed = NULL, *drft = NULL, *msgnam = NULL;
char buf[BUFSIZ], prompt[BUFSIZ];
char **argp, **arguments;
print_version(invo_name);
done (1);
- 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 EDITRSW:
if (!(ed = *argp++) || *ed == '-')
adios (NULL, "missing argument to %s", argp[-2]);
}
if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
- drft = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
+ drft = getcpy (m_draft("cur"));
msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
showfile (++argp, drft);
break;
- case WHOMSW:
- /* Check to whom the draft would be sent */
- whomfile (++argp, drft);
- break;
-
case QUITSW:
/* Quit, and possibly delete the draft */
if (*++argp && (*argp[0] == 'd' ||
{ "push", 0 },
#define NSPSHSW 13
{ "nopush", 0 },
-#define SPLITSW 14
- { "split seconds", 0 },
-#define UNIQSW 15
+#define UNIQSW 14
{ "unique", -6 },
-#define NUNIQSW 16
+#define NUNIQSW 15
{ "nounique", -8 },
-#define VERBSW 17
+#define VERBSW 16
{ "verbose", 0 },
-#define NVERBSW 18
+#define NVERBSW 17
{ "noverbose", 0 },
-#define WATCSW 19
+#define WATCSW 18
{ "watch", 0 },
-#define NWATCSW 20
+#define NWATCSW 19
{ "nowatch", 0 },
-#define WIDTHSW 21
+#define WIDTHSW 20
{ "width columns", 0 },
-#define SVERSIONSW 22
+#define SVERSIONSW 21
{ "version", 0 },
-#define SHELPSW 23
+#define SHELPSW 22
{ "help", 0 },
-#define BITSTUFFSW 24
+#define BITSTUFFSW 23
{ "dashstuffing", -12 },
-#define NBITSTUFFSW 25
+#define NBITSTUFFSW 24
{ "nodashstuffing", -14 },
-#define MAILSW 26
+#define MAILSW 25
{ "mail", -4 },
-#define SAMLSW 27
+#define SAMLSW 26
{ "saml", -4 },
-#define SSNDSW 28
+#define SSNDSW 27
{ "send", -4 },
-#define SOMLSW 29
+#define SOMLSW 28
{ "soml", -4 },
-#define CLIESW 30
+#define CLIESW 29
{ "client host", -6 },
-#define SERVSW 31
+#define SERVSW 30
{ "server host", 6 },
-#define SNOOPSW 32
+#define SNOOPSW 31
{ "snoop", -5 },
-#define SDRFSW 33
- { "draftfolder +folder", -6 },
-#define SDRMSW 34
- { "draftmessage msg", -6 },
-#define SNDRFSW 35
- { "nodraftfolder", -3 },
-#define SNDATTACHSW 39
+#define SNDATTACHSW 32
{ "attach file", 6 },
-#define SNDATTACHFORMAT 40
+#define SNDATTACHFORMAT 33
{ "attachformat", 7 },
-#define PORTSW 41
+#define PORTSW 34
{ "port server-port-name/number", 4 },
{ NULL, 0 }
};
extern int forwsw;
extern int inplace;
extern int pushsw;
-extern int splitsw;
extern int unique;
extern int verbsw;
pushed = 0;
continue;
- case SPLITSW:
- if (!(cp = *argp++) || sscanf (cp, "%d", &splitsw) != 1) {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- continue;
-
case UNIQSW:
unique++;
continue;
vec[vecp++] = cp;
continue;
- case SDRFSW:
- case SDRMSW:
- if (!(cp = *argp++) || *cp == '-') {
- advise (NULL, "missing argument to %s", argp[-2]);
- return;
- }
- case SNDRFSW:
- continue;
-
case SNDATTACHSW:
if (!(attach = *argp++) || *attach == '-') {
advise (NULL, "missing argument to %s", argp[-2]);
done (0);
}
-/*
- * WHOM
- */
-
-static int
-whomfile (char **arg, char *file)
-{
- pid_t pid;
- int vecp;
- char *vec[MAXARGS];
-
- context_save (); /* save the context file */
- fflush (stdout);
-
- switch (pid = vfork ()) {
- case NOTOK:
- advise ("fork", "unable to");
- return 1;
-
- case OK:
- vecp = 0;
- vec[vecp++] = r1bindex (whomproc, '/');
- vec[vecp++] = file;
- if (arg)
- while (*arg)
- vec[vecp++] = *arg++;
- vec[vecp] = NULL;
-
- execvp (whomproc, vec);
- fprintf (stderr, "unable to exec ");
- perror (whomproc);
- _exit (-1); /* NOTREACHED */
-
- default:
- return (pidwait (pid, NOTOK) & 0377 ? 1 : 0);
- }
-}
-
/*
* Remove the draft file