- if (!context_find ("path"))
- free (path ("./", TFOLDER));
-
- /*
- * Check if we are using a draft folder
- * and have specified a message in it.
- */
- if ((dfolder || context_find ("Draft-Folder")) && !folder && msg && !file) {
- file = msg;
- msg = NULL;
- }
- if (form && (folder || msg))
- adios (NULL, "can't mix forms and folders/msgs");
-
- if (folder || msg) {
- /*
- * Use a message as the "form" for the new message.
- */
- if (!msg)
- msg = "cur";
- if (!folder)
- folder = getfolder (1);
- maildir = m_maildir (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 the message range/sequence/name and set SELECTED */
- if (!m_convert (mp, msg))
- done (1);
- seq_setprev (mp); /* set the previous-sequence */
-
- if (mp->numsel > 1)
- adios (NULL, "only one message at a time!");
-
- if ((in = open (form = getcpy (m_name (mp->lowsel)), O_RDONLY)) == NOTOK)
- adios (form, "unable to open message");
- } else
- in = open_form(&form, components);
-
-try_it_again:
- strncpy (drft, m_draft (dfolder, file, use, &isdf), sizeof(drft));
-
- /*
- * Check if we have an existing draft
- */
- if ((out = open (drft, O_RDONLY)) != NOTOK) {
- i = fdcompare (in, out);
- close (out);
-
- /*
- * If we have given -use flag, or if the
- * draft is just the same as the components
- * file, then no need to ask any questions.
- */
- if (use || i)
- goto edit_it;
-
- if (stat (drft, &st) == NOTOK)
- adios (drft, "unable to stat");
- printf ("Draft \"%s\" exists (%ld bytes).", drft, (long) st.st_size);
- for (i = LISTDSW; i != YESW;) {
- if (!(argp = getans ("\nDisposition? ", isdf ? aqrunl : aqrul)))
- done (1);
- switch (i = smatch (*argp, isdf ? aqrunl : aqrul)) {
- case NOSW:
- done (0);
- case NEWSW:
- file = NULL;
- use = NOUSE;
- goto try_it_again;
- case YESW:
- break;
- case USELSW:
- use++;
- goto edit_it;
- case LISTDSW:
- showfile (++argp, drft);
- break;
- case REFILSW:
- if (refile (++argp, drft) == 0)
- i = YESW;
- break;
- default:
- advise (NULL, "say what?");
- break;
- }