Removed the draft message in favor for a consistent draft folder facility
[mmh] / uip / comp.c
index f713b6f..554d310 100644 (file)
 #include <fcntl.h>
 
 static struct swit switches[] = {
-#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 FILESW  5
-       { "file file", 0 },
-#define FORMSW  6
+#define FORMSW  2
        { "form formfile", 0 },
-#define USESW  7
+#define USESW  3
        { "use", 0 },
-#define NUSESW  8
+#define NUSESW  4
        { "nouse", 0 },
-#define WHATSW  9
+#define WHATSW  5
        { "whatnowproc program", 0 },
-#define NWHATSW  10
+#define NWHATSW  6
        { "nowhatnowproc", 0 },
-#define VERSIONSW  11
+#define VERSIONSW  7
        { "version", 0 },
-#define HELPSW  12
+#define HELPSW  8
        { "help", 0 },
        { NULL, 0 }
 };
@@ -56,23 +48,14 @@ static struct swit aqrunl[] = {
        { NULL, 0 }
 };
 
-static struct swit aqrul[] = {
-       { "quit", 0 },
-       { "replace", 0 },
-       { "use", 0 },
-       { "list", 0 },
-       { "refile", 0 },
-       { NULL, 0 }
-};
-
 
 int
 main (int argc, char **argv)
 {
        int use = NOUSE, nedit = 0, nwhat = 0;
-       int i, in, isdf = 0, out;
-       char *cp, *cwd, *maildir, *dfolder = NULL;
-       char *ed = NULL, *file = NULL, *form = NULL;
+       int i, in, out;
+       char *cp, *cwd, *maildir;
+       char *ed = NULL, *form = NULL;
        char *folder = NULL, *msg = NULL, buf[BUFSIZ];
        char drft[BUFSIZ], **argp, **arguments;
        struct msgs *mp = NULL;
@@ -136,33 +119,6 @@ main (int argc, char **argv)
                                case NUSESW:
                                        use = NOUSE;
                                        continue;
-
-                               case FILESW:  /* compatibility */
-                                       if (file)
-                                               adios (NULL, "only one file at a time!");
-                                       if (!(file = *argp++) || *file == '-')
-                                               adios (NULL, "missing argument to %s", argp[-2]);
-                                       isdf = NOTOK;
-                                       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 (file)
-                                               adios (NULL, "only one draft message at a time!");
-                                       if (!(file = *argp++) || *file == '-')
-                                               adios (NULL, "missing argument to %s", argp[-2]);
-                                       continue;
-                               case NDFLDSW:
-                                       dfolder = NULL;
-                                       isdf = NOTOK;
-                                       continue;
                        }
                }
                if (*cp == '+' || *cp == '@') {
@@ -183,20 +139,12 @@ main (int argc, char **argv)
        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) {
+       if (!use && (folder || msg)) {
                /*
-                * Use a message as the "form" for the new message.
+                * Take a message as the "form" for the new message.
                 */
                if (!msg)
                        msg = "cur";
@@ -223,13 +171,14 @@ main (int argc, char **argv)
                if (mp->numsel > 1)
                        adios (NULL, "only one message at a time!");
 
-               if ((in = open (form = getcpy (m_name (mp->lowsel)), O_RDONLY)) == NOTOK)
+               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));
+       strncpy (drft, m_draft(use ? (msg?msg:"cur") : "new"), sizeof(drft));
 
        /*
         * Check if we have an existing draft
@@ -250,13 +199,12 @@ try_it_again:
                        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)))
+                       if (!(argp = getans ("\nDisposition? ", aqrunl)))
                                done (1);
-                       switch (i = smatch (*argp, isdf ? aqrunl : aqrul)) {
+                       switch (i = smatch (*argp, aqrunl)) {
                                case NOSW:
                                        done (0);
                                case NEWSW:
-                                       file = NULL;
                                        use = NOUSE;
                                        goto try_it_again;
                                case YESW: