]> diplodocus.org Git - nmh/blobdiff - uip/show.c
We never use the autoconf checks for errno.h, crypt.h, or netdb.h, so
[nmh] / uip / show.c
index ff2043589e0f669c427fa831a83c8ae16f721f0b..229e6eddf6347ec3531f7aede1cd934f1fa03ac1 100644 (file)
 #include <h/mime.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define CHECKMIMESW          0
-    { "checkmime", 0 },
-#define NOCHECKMIMESW        1
-    { "nocheckmime", 0 },
-#define        HEADSW               2
-    { "header", 0 },
-#define        NHEADSW              3
-    { "noheader", 0 },
-#define        FORMSW               4
-    { "form formfile", 0 },
-#define        PROGSW               5
-    { "moreproc program", 0 },
-#define        NPROGSW              6
-    { "nomoreproc", 0 },
-#define        LENSW                7
-    { "length lines", 0 },
-#define        WIDTHSW              8
-    { "width columns", 0 },
-#define        SHOWSW               9
-    { "showproc program", 0 },
-#define SHOWMIMESW          10
-    { "showmimeproc program", 0 },
-#define        NSHOWSW             11
-    { "noshowproc", 0 },
-#define        DRFTSW              12
-    { "draft", 0 },
-#define        FILESW              13
-    { "file file", -4 },               /* interface from showfile */
-#define FMTPROCSW           14
-    { "fmtproc program", 0 },
-#define NFMTPROCSW          15
-    { "nofmtproc", 0 },
-#define VERSIONSW           16
-    { "version", 0 },
-#define        HELPSW              17
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SHOW_SWITCHES \
+    X("checkmime", 0, CHECKMIMESW) \
+    X("nocheckmime", 0, NOCHECKMIMESW) \
+    X("header", 0, HEADSW) \
+    X("noheader", 0, NHEADSW) \
+    X("form formfile", 0, FORMSW) \
+    X("moreproc program", 0, PROGSW) \
+    X("nomoreproc", 0, NPROGSW) \
+    X("length lines", 0, LENSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("showproc program", 0, SHOWSW) \
+    X("showmimeproc program", 0, SHOWMIMESW) \
+    X("noshowproc", 0, NSHOWSW) \
+    X("draft", 0, DRFTSW) \
+    X("file file", -4, FILESW) /* interface from showfile */ \
+    X("fmtproc program", 0, FMTPROCSW) \
+    X("nofmtproc", 0, NFMTPROCSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SHOW, switches);
+#undef X
 
 /*
  * static prototypes
@@ -66,7 +54,7 @@ main (int argc, char **argv)
 {
     int draftsw = 0, headersw = 1;
     int nshow = 0, checkmime = 1, mime;
-    int procp = 1, isdf = 0, mode = SHOW, msgnum;
+    int isdf = 0, mode = SHOW, msgnum;
     char *cp, *maildir, *file = NULL, *folder = NULL, *proc;
     char buf[BUFSIZ], **argp, **arguments;
     struct msgs *mp = NULL;
@@ -191,7 +179,6 @@ usage:
                app_msgarg(&msgs, cp);
        }
     }
-    procp = vec.size;
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
@@ -330,23 +317,6 @@ go_to_it: ;
        done (0);
     }
 
-    /*
-     * If you are not using a nmh command as your "proc", then
-     * add the path to the message names.  Currently, we are just
-     * checking for mhn here, since we've already taken care of mhl.
-     */
-    if (!strcmp (r1bindex (proc, '/'), "mhl")
-           && !draftsw
-           && !file
-           && chdir (maildir = concat (m_maildir (""), "/", NULL)) != NOTOK) {
-       mp->foldpath = concat (mp->foldpath, "/", NULL);
-       cp = ssequal (maildir, mp->foldpath)
-           ? mp->foldpath + strlen (maildir)
-           : mp->foldpath;
-       for (msgnum = procp; msgnum < vec.size; msgnum++)
-           vec.msgs[msgnum] = concat (cp, vec.msgs[msgnum], NULL);
-    }
-
     vec.msgs[0] = r1bindex (proc, '/');
     app_msgarg(&vec, NULL);
     execvp (proc, vec.msgs);