- int isdf = 0, nedit = 0, use = 0;
- char *cp, *dfolder = NULL, *dmsg = NULL;
- char *ed = NULL, *drft = NULL, *msgnam = NULL;
- char buf[BUFSIZ], prompt[BUFSIZ];
- char **argp, **arguments;
- struct stat st;
- char *attach = (char *)0; /* attachment header field name */
- char cwd[MAXPATHLEN + 1]; /* current working directory */
- char file[MAXPATHLEN + 1]; /* file name buffer */
- char shell[MAXPATHLEN + 1]; /* shell response buffer */
- FILE *f; /* read pointer for bgnd proc */
- char *l; /* set on -l to alist command */
- int n; /* set on -n to alist command */
-
- invo_name = r1bindex (argv[0], '/');
-
- /* read user profile/context */
- context_read();
-
- arguments = getarguments (invo_name, argc, argv, 1);
- argp = arguments;
-
- /*
- * Get the initial current working directory.
- */
-
- if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
- adios("getcwd", "could not get working directory");
- }
-
- while ((cp = *argp++)) {
- if (*cp == '-') {
- switch (smatch (++cp, whatnowswitches)) {
- case AMBIGSW:
- ambigsw (cp, whatnowswitches);
- done (1);
- case UNKWNSW:
- adios (NULL, "-%s unknown", cp);
-
- case HELPSW:
- snprintf (buf, sizeof(buf), "%s [switches] [file]", invo_name);
- print_help (buf, whatnowswitches, 1);
- done (1);
- case VERSIONSW:
- 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]);
- nedit = 0;
- continue;
- case NEDITSW:
- nedit++;
- continue;
-
- case PRMPTSW:
- if (!(myprompt = *argp++) || *myprompt == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
-
- case ATTACHSW:
- if (attach != (char *)0)
- adios(NULL, "only one attachment header field name at a time!");
- if (!(attach = *argp++) || *attach == '-')
- adios (NULL, "missing argument to %s", argp[-2]);
- continue;
- }
- }
- if (drft)
- adios (NULL, "only one draft at a time!");
- else
- drft = cp;
- }
-
- if ((drft == NULL && (drft = getenv ("mhdraft")) == NULL) || *drft == 0)
- drft = getcpy (m_draft (dfolder, dmsg, 1, &isdf));
-
- msgnam = (cp = getenv ("mhaltmsg")) && *cp ? getcpy (cp) : NULL;
-
- if ((cp = getenv ("mhuse")) && *cp)
- use = atoi (cp);
-
- if (ed == NULL && ((ed = getenv ("mheditor")) == NULL || *ed == 0)) {
- ed = NULL;
- nedit++;
- }
-
- /* start editing the draft, unless -noedit was given */
- if (!nedit && editfile (&ed, NULL, drft, use, NULL, msgnam, NULL, 1) < 0)
- done (1);
-
- snprintf (prompt, sizeof(prompt), myprompt, invo_name);
- for (;;) {
- if (!(argp = getans (prompt, aleqs))) {
- unlink (LINK);
- done (1);
+ int nedit = 0, use = 0;
+ char *cp;
+ char *ed = NULL, *drft = NULL, *msgnam = NULL;
+ char buf[BUFSIZ], prompt[BUFSIZ];
+ char **argp, **arguments;
+ struct stat st;
+ char *attach = (char *)0; /* attachment header field name */
+ char cwd[MAXPATHLEN + 1]; /* current working directory */
+ char file[MAXPATHLEN + 1]; /* file name buffer */
+ char shell[MAXPATHLEN + 1]; /* shell response buffer */
+ FILE *f; /* read pointer for bgnd proc */
+ char *l; /* set on -l to alist command */
+ int n; /* set on -n to alist command */
+
+ invo_name = mhbasename(argv[0]);
+
+ /* read user profile/context */
+ context_read();
+
+ arguments = getarguments(invo_name, argc, argv, 1);
+ argp = arguments;
+
+ /*
+ ** Get the initial current working directory.
+ */
+
+ if (getcwd(cwd, sizeof (cwd)) == (char *)0) {
+ adios("getcwd", "could not get working directory");