Renamed -version switch to -Version to remove the conflict with -verbose.
[mmh] / uip / comp.c
index ce76cd8..1c45a98 100644 (file)
 static struct swit switches[] = {
 #define EDITRSW  0
        { "editor editor", 0 },
-#define NEDITSW  1
-       { "noedit", 0 },
-#define FORMSW  2
+#define FORMSW  1
        { "form formfile", 0 },
-#define USESW  3
+#define USESW  2
        { "use", 0 },
-#define NUSESW  4
+#define NUSESW  3
        { "nouse", 0 },
-#define WHATSW  5
+#define WHATSW  4
        { "whatnowproc program", 0 },
-#define NWHATSW  6
-       { "nowhatnowproc", 0 },
-#define VERSIONSW  7
-       { "version", 0 },
-#define HELPSW  8
+#define VERSIONSW  5
+       { "Version", 0 },
+#define HELPSW  6
        { "help", 0 },
        { NULL, 0 }
 };
@@ -36,13 +32,15 @@ static struct swit switches[] = {
 int
 main(int argc, char **argv)
 {
-       int use = NOUSE, nedit = 0, nwhat = 0;
+       int use = NOUSE;
        int 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;
+       char *fmtstr;
+
 
 #ifdef LOCALE
        setlocale(LC_ALL, "");
@@ -75,19 +73,11 @@ main(int argc, char **argv)
                        case EDITRSW:
                                if (!(ed = *argp++) || *ed == '-')
                                        adios(NULL, "missing argument to %s", argp[-2]);
-                               nedit = 0;
-                               continue;
-                       case NEDITSW:
-                               nedit++;
                                continue;
 
                        case WHATSW:
                                if (!(whatnowproc = *argp++) || *whatnowproc == '-')
                                        adios(NULL, "missing argument to %s", argp[-2]);
-                               nwhat = 0;
-                               continue;
-                       case NWHATSW:
-                               nwhat++;
                                continue;
 
                        case FORMSW:
@@ -162,23 +152,19 @@ main(int argc, char **argv)
                close(out);
 
        } else {
-               in = open_form(&form, components);
-
+               fmtstr = new_fs(form, components);
                strncpy(drft, m_draft(seq_beyond), sizeof(drft));
                if ((out = creat(drft, m_gmprot())) == NOTOK) {
                        adios(drft, "unable to create");
                }
-               cpydata(in, out, form, drft);
-               close(in);
+               if (write(out, fmtstr, strlen(fmtstr)) != (int)strlen(fmtstr)) {
+                       adios(drft, "error writing");
+               }
                close(out);
        }
 
        context_save();
-
-       if (nwhat) {
-               done(0);
-       }
-       what_now(ed, nedit, use, drft, NULL, 0, NULLMP, NULL, cwd);
+       what_now(ed, use, drft, NULL, 0, NULLMP, NULL, cwd);
        done(1);
        return 1;
 }