]> diplodocus.org Git - nmh/commitdiff
Convert all argument processing over to using X-Macros for cleanup.
authorKen Hornstein <kenh@pobox.com>
Thu, 10 Jan 2013 03:04:23 +0000 (22:04 -0500)
committerKen Hornstein <kenh@pobox.com>
Thu, 10 Jan 2013 03:04:23 +0000 (22:04 -0500)
Based on a suggestion by Ralph Corderoy.

53 files changed:
config/config.c
h/mh.h
sbr/smatch.c
uip/ali.c
uip/anno.c
uip/ap.c
uip/burst.c
uip/comp.c
uip/conflict.c
uip/dist.c
uip/dp.c
uip/flist.c
uip/fmtdump.c
uip/folder.c
uip/forw.c
uip/inc.c
uip/install-mh.c
uip/mark.c
uip/mhbuild.c
uip/mhlist.c
uip/mhlsbr.c
uip/mhn.c
uip/mhparam.c
uip/mhpath.c
uip/mhshow.c
uip/mhstore.c
uip/mhstoresbr.c
uip/mhtest.c
uip/msgchk.c
uip/msh.c
uip/mshcmds.c
uip/new.c
uip/packf.c
uip/pick.c
uip/picksbr.c
uip/post.c
uip/prompter.c
uip/rcvdist.c
uip/rcvpack.c
uip/rcvstore.c
uip/rcvtty.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/send.c
uip/show.c
uip/slocal.c
uip/sortm.c
uip/viamail.c
uip/whatnowsbr.c
uip/whom.c

index 72da2cd97c6ab1f9e222d84b7e97761545d8ae80..f78c1478ef112a35e197c12a7574bcb790c844bb 100644 (file)
@@ -83,9 +83,9 @@ try_it:
  */
 
 struct swit anoyes[] = {
-    { "no", 0 },
-    { "yes", 0 },
-    { NULL, 0 }
+    { "no", 0, 0 },
+    { "yes", 0, 1 },
+    { NULL, 0, 0 }
 };
 
 /* 
diff --git a/h/mh.h b/h/mh.h
index 225d0c91ff5b3c7d415f70f1e1e936fa41a472ef..5bf279abe6b4cbf34b0506180e1bd6eef955ee4f 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -55,6 +55,11 @@ struct node {
 #define        UNKWNSW  (-1)   /* from smatch() on unknown switch   */
 
 struct swit {
+
+    /*
+     * Switch name
+     */
+
     char *sw;
 
     /* The minchars field is apparently used like this:
@@ -63,8 +68,54 @@ struct swit {
        0  : Switch can't be abbreviated;               switch shown in -help.
        #  : Switch can be abbreviated to # characters; switch shown in -help. */
     int minchars;
+
+    /*
+     * If we pick this switch, return this value from smatch
+     */
+
+    int swret;
 };
 
+/*
+ * Macros to use when declaring struct swit arrays.
+ *
+ * These macros are what known as X-Macros.  In your source code you
+ * use them like this:
+ *
+ * #define FOO_SWITCHES \
+ *    X("switch1", 0, SWITCHSW) \
+ *    X("switch2", 0, SWITCH2SW) \
+ *    X("thirdswitch", 2, SWITCH3SW) \
+ *
+ * The argument to each entry in FOO_SWITCHES are the switch name (sw),
+ * the minchars field (see above) and the return value for this switch.
+ *
+ * After you define FOO_SWITCHES, you instantiate it as follows:
+ *
+ * #define X(sw, minchars, id) id,
+ * DEFINE_SWITCH_ENUM(FOO);
+ * #undef X
+ *
+ * #define X(sw, minchars, id) { sw, minchars, id },
+ * DEFINE_SWITCH_ARRAY(FOO);
+ * #undef X
+ *
+ * DEFINE_SWITCH_ENUM defines an extra enum at the end of the list called
+ * LEN_FOO.
+ */
+
+#define DEFINE_SWITCH_ENUM(name) \
+    enum { \
+       name ## _SWITCHES \
+       LEN_ ## name \
+    }
+
+#define DEFINE_SWITCH_ARRAY(name, array) \
+    static struct swit array[] = { \
+       name ## _SWITCHES \
+       { NULL, 0, 0 } \
+    }
+
 extern struct swit anoyes[];   /* standard yes/no switches */
 
 #define ATTACHFORMATS 3                /* Number of send attach formats. */
index 88a098b3a0e629678b3c386eb1f51e728aacf33f..4d1d3d6814b7f977897a2dbd22819de3ee220788 100644 (file)
@@ -29,16 +29,16 @@ smatch(char *string, struct swit *swp)
            continue;                   /* no match */
        for (sp = string; *sp == *tcp++;) {
            if (*sp++ == '\0')
-               return (tp - swp);      /* exact match */
+               return tp->swret;       /* exact match */
        }
        if (*sp) {
            if (*sp != ' ')
                continue;               /* no match */
            if (*--tcp == '\0')
-               return (tp - swp);      /* exact match */
+               return tp->swret;       /* exact match */
        }
        if (firstone == UNKWNSW)
-           firstone = tp - swp;
+           firstone = tp->swret;
        else
            firstone = AMBIGSW;
     }
index 880fe2123e4ddbe79216bb06d6d461bf5ad99605..3893a1d8ad16c1455cb6abee3bd1dab18d4d3ac4 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
 #include <h/mts.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        ALIASW                0
-    { "alias aliasfile", 0 },
-#define        NALIASW               1
-    { "noalias", -7 },
-#define        LISTSW                2
-    { "list", 0 },
-#define        NLISTSW               3
-    { "nolist", 0 },
-#define        NORMSW                4
-    { "normalize", 0 },
-#define        NNORMSW               5
-    { "nonormalize", 0 },
-#define        USERSW                6
-    { "user", 0 },
-#define        NUSERSW               7
-    { "nouser", 0 },
-#define VERSIONSW             8
-    { "version", 0 },
-#define        HELPSW                9
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define ALI_SWITCHES \
+    X("alias aliasfile", 0, ALIASW) \
+    X("noalias", -7, NALIASW) \
+    X("list", 0, LISTSW) \
+    X("nolist", 0, NLISTSW) \
+    X("normalize", 0, NORMSW) \
+    X("nonormalize", 0, NNORMSW) \
+    X("user", 0, USERSW) \
+    X("nouser", 0, NUSERSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(ALI);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(ALI, switches);
+#undef X
 
 static int pos = 1;
 
index 24726d7f458795b7c11c7c5bc666bcce1d6ae153..0ed6e77f98d9da60e055947be14b828004015e3b 100644 (file)
 #include <h/mh.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        COMPSW  0
-    { "component field", 0 },
-#define        INPLSW  1
-    { "inplace", 0 },
-#define        NINPLSW 2
-    { "noinplace", 0 },
-#define        DATESW  3
-    { "date", 0 },
-#define        NDATESW 4
-    { "nodate", 0 },
-#define        TEXTSW  5
-    { "text body", 0 },
-#define VERSIONSW 6
-    { "version", 0 },
-#define        HELPSW  7
-    { "help", 0 },
-#define        DRFTSW                   8
-    { "draft", 2 },
-#define        LISTSW                   9
-    { "list", 1 },
-#define        DELETESW                10
-    { "delete", 2 },
-#define        NUMBERSW                11
-    { "number", 2 },
-#define        APPENDSW                12
-    { "append", 1 },
-#define        PRESERVESW              13
-    { "preserve", 1 },
-#define        NOPRESERVESW            14
-    { "nopreserve", 3 },
-    { NULL, 0 }
-};
+#define ANNO_SWITCHES \
+    X("component field", 0, COMPSW) \
+    X("inplace", 0, INPLSW) \
+    X("noinplace", 0, NINPLSW) \
+    X("date", 0, DATESW) \
+    X("nodate", 0, NDATESW) \
+    X("text body", 0, TEXTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("draft", 2, DRFTSW) \
+    X("list", 1, LISTSW) \
+    X("delete", 2, DELETESW) \
+    X("number", 2, NUMBERSW) \
+    X("append", 1, APPENDSW) \
+    X("preserve", 1, PRESERVESW) \
+    X("nopreserve", 3, NOPRESERVESW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(ANNO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(ANNO, switches);
+#undef X
 
 /*
  * static prototypes
index 80ce8a3fa43ac7087c2d18971979e48fc8fa13bb..105c3fe4d080dd5bca79f77e5f45fdb003ffae93 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
 
 #define        FORMAT  "%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>"
 
-static struct swit switches[] = {
-#define        FORMSW  0
-    { "form formatfile", 0 },
-#define        FMTSW   1
-    { "format string", 5 },
-#define        NORMSW  2
-    { "normalize", 0 },
-#define        NNORMSW 3
-    { "nonormalize", 0 },
-#define        WIDTHSW 4
-    { "width columns", 0 },
-#define VERSIONSW 5
-    { "version", 0 },
-#define        HELPSW  6
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define AP_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("normalize", 0, NORMSW) \
+    X("nonormalize", 0, NNORMSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(AP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(AP, switches);
+#undef X
 
 static struct format *fmt;
 
index 93fd5e03b8b4b41ca0fb0186f1c7264c228741fa..0b4a240921eac666a11c7ac2fd96628898fe56ee 100644 (file)
 #include <h/mh.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        INPLSW  0
-    { "inplace", 0 },
-#define        NINPLSW 1
-    { "noinplace", 0 },
-#define        QIETSW  2
-    { "quiet", 0 },
-#define        NQIETSW 3
-    { "noquiet", 0 },
-#define        VERBSW  4
-    { "verbose", 0 },
-#define        NVERBSW 5
-    { "noverbose", 0 },
-#define VERSIONSW 6
-    { "version", 0 },
-#define        HELPSW  7
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define BURST_SWITCHES \
+    X("inplace", 0, INPLSW) \
+    X("noinplace", 0, NINPLSW) \
+    X("quiet", 0, QIETSW) \
+    X("noquiet", 0, NQIETSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(BURST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(BURST, switches);
+#undef X
 
 struct smsg {
     off_t s_start;
index 65b213aef9b84f7b36bba619d313bbb435f5b2ca..0b0ac369f804a66f169f4398be211432ec6b8793 100644 (file)
 #include <h/fmt_scan.h>
 #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
-    { "editor editor", 0 },
-#define        NEDITSW                4
-    { "noedit", 0 },
-#define        FILESW                 5
-    { "file file", 0 },
-#define        FORMSW                 6
-    { "form formfile", 0 },
-#define        USESW                  7
-    { "use", 0 },
-#define        NUSESW                 8
-    { "nouse", 0 },
-#define        WHATSW                 9
-    { "whatnowproc program", 0 },
-#define        NWHATSW               10
-    { "nowhatnowproc", 0 },
-#define VERSIONSW             11
-    { "version", 0 },
-#define        HELPSW                12
-    { "help", 0 },
-#define TOSW                  13
-    { "to address", 0 },
-#define CCSW                  14
-    { "cc address", 0 },
-#define FROMSW                15
-    { "from address", 0 },
-#define FCCSW                 16
-    { "fcc mailbox", 0 },
-#define WIDTHSW                      17
-    { "width colums", 0 },
-#define SUBJECTSW             18
-    { "subject text", 0 },
-    { NULL, 0 }
-};
-
-static struct swit aqrunl[] = {
-#define        NOSW          0
-    { "quit", 0 },
-#define        YESW          1
-    { "replace", 0 },
-#define        USELSW        2
-    { "use", 0 },
-#define        LISTDSW       3
-    { "list", 0 },
-#define        REFILSW       4
-    { "refile +folder", 0 },
-#define NEWSW         5
-    { "new", 0 },
-    { NULL, 0 }
-};
+#define COMP_SWITCHES \
+    X("draftfolder +folder", 0, DFOLDSW) \
+    X("draftmessage msg", 0, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("editor editor", 0, EDITRSW) \
+    X("noedit", 0, NEDITSW) \
+    X("file file", 0, FILESW) \
+    X("form formfile", 0, FORMSW) \
+    X("use", 0, USESW) \
+    X("nouse", 0, NUSESW) \
+    X("whatnowproc program", 0, WHATSW) \
+    X("nowhatnowproc", 0, NWHATSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("to address", 0, TOSW) \
+    X("cc address", 0, CCSW) \
+    X("from address", 0, FROMSW) \
+    X("fcc mailbox", 0, FCCSW) \
+    X("width colums", 0, WIDTHSW) \
+    X("subject text", 0, SUBJECTSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(COMP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(COMP, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+    X("quit", 0, NOSW) \
+    X("replace", 0, YESW) \
+    X("use", 0, USELSW) \
+    X("list", 0, LISTDSW) \
+    X("refile +folder", 0, REFILSW) \
+    X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrunl);
+#undef X
 
 static struct swit aqrul[] = {
-    { "quit", 0 },
-    { "replace", 0 },
-    { "use", 0 },
-    { "list", 0 },
-    { "refile", 0 },
-    { NULL, 0 }
+    { "quit", 0, NOSW },
+    { "replace", 0, YESW },
+    { "use", 0, USELSW },
+    { "list", 0, LISTDSW },
+    { "refile", 0, REFILSW },
+    { NULL, 0, 0 }
 };
 
 int
index 2324c650a4eabab9672695835eb29b491a1dfc4c..d8c45669720075eb9f96e825b6d783725db84cf9 100644 (file)
  */
 #define        NGRPS   100
 
-static struct swit switches[] = {
-#define        MAILSW         0
-    { "mail name", 0 },
-#define        SERCHSW        1
-    { "search directory", 0 },
-#define VERSIONSW      2
-    { "version", 0 },
-#define        HELPSW         3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define CONFLICT_SWITCHES \
+    X("mail name", 0, MAILSW) \
+    X("search directory", 0, SERCHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(CONFLICT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(CONFLICT, switches);
+#undef X
 
 static char *mail = NULL;
 static char *dirs[NDIRS];
index b7799beb7067e50cb65c5c3e371a62dbc258d4f2..29820f300bad5d784315aea246c393763a2765b2 100644 (file)
 #include <h/utils.h>
 #include <fcntl.h>
 
-static struct swit switches[] = {
-#define        ANNOSW  0
-    { "annotate", 0 },
-#define        NANNOSW 1
-    { "noannotate", 0 },
-#define        DFOLDSW 2
-    { "draftfolder +folder", 0 },
-#define        DMSGSW  3
-    { "draftmessage msg", 0 },
-#define        NDFLDSW 4
-    { "nodraftfolder", 0 },
-#define        EDITRSW 5
-    { "editor editor", 0 },
-#define        NEDITSW 6
-    { "noedit", 0 },
-#define        FORMSW  7
-    { "form formfile", 0 },
-#define        INPLSW  8
-    { "inplace", 0 },
-#define        NINPLSW 9
-    { "noinplace", 0 },
-#define        WHATSW  10
-    { "whatnowproc program", 0 },
-#define        NWHATSW 11
-    { "nowhatnowproc", 0 },
-#define VERSIONSW 12
-    { "version", 0 },
-#define        HELPSW  13
-    { "help", 0 },
-#define        FILESW  14
-    { "file file", -4 },       /* interface from msh */
-#define FROMSW  15
-    { "from address", 0 },
-#define TOSW    16
-    { "to address", 0 },
-#define CCSW    17
-    { "cc address", 0 },
-#define FCCSW   18
-    { "fcc mailbox", 0 },
-#define WIDTHSW 19
-    { "width columns", 0 },
-#define ATFILESW 20
-    { "atfile", 0 },
-#define NOATFILESW 21
-    { "noatfile", 0 },
-    { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define        NOSW    0
-    { "quit", 0 },
-#define        YESW    1
-    { "replace", 0 },
-#define        LISTDSW 2
-    { "list", 0 },
-#define        REFILSW 3
-    { "refile +folder", 0 },
-#define NEWSW  4
-    { "new", 0 },
-    { NULL, 0 }
-};
+#define DIST_SWITCHES \
+    X("annotate", 0, ANNOSW) \
+    X("noannotate", 0, NANNOSW) \
+    X("draftfolder +folder", 0, DFOLDSW) \
+    X("draftmessage msg", 0, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("editor editor", 0, EDITRSW) \
+    X("noedit", 0, NEDITSW) \
+    X("form formfile", 0, FORMSW) \
+    X("inplace", 0, INPLSW) \
+    X("noinplace", 0, NINPLSW) \
+    X("whatnowproc program", 0, WHATSW) \
+    X("nowhatnowproc", 0, NWHATSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("file file", -4, FILESW) \
+    X("from address", 0, FROMSW) \
+    X("to address", 0, TOSW) \
+    X("cc address", 0, CCSW) \
+    X("fcc mailbox", 0, FCCSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("atfile", 0, ATFILESW) \
+    X("noatfile", 0, NOATFILESW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DIST, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+    X("quit", 0, NOSW) \
+    X("replace", 0, YESW) \
+    X("list", 0, LISTDSW) \
+    X("refile +folder", 0, REFILSW) \
+    X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
 
 
 static struct swit aqrl[] = {
-    { "quit", 0 },
-    { "replace", 0 },
-    { "list", 0 },
-    { "refile +folder", 0 },
+    { "quit", 0, NOSW },
+    { "replace", 0, YESW },
+    { "list", 0, LISTDSW },
+    { "refile +folder", 0, REFILSW },
     { NULL, 0 }
 };
 
index b9158459be7ab6236bca8bd63fb457b63c569d58..eef77908115421b0cbd1671e9f394801025dda9a 100644 (file)
--- a/uip/dp.c
+++ b/uip/dp.c
 
 #define        FORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
 
-static struct swit switches[] = {
-#define        FORMSW                0
-    { "form formatfile", 0 },
-#define        FMTSW                 1
-    { "format string", 5 },
-#define        WIDTHSW               2
-    { "width columns", 0 },
-#define VERSIONSW             3
-    { "version", 0 },
-#define        HELPSW                4
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define DP_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DP, switches);
+#undef X
 
 static struct format *fmt;
 
index b4aff9cd3882a980003487950ae1562513d8ccb8..4c0469edff755d822ca315ebb3d610fdd1120036 100644 (file)
 #define MAXFOLDERS  100
 
 
-static struct swit switches[] = {
-#define SEQSW           0
-    { "sequence name", 0 },
-#define ALLSW           1
-    { "all", 0 },
-#define NOALLSW         2
-    { "noall", 0 },
-#define RECURSE         3
-    { "recurse", 0 },
-#define NORECURSE       4
-    { "norecurse", 0 },
-#define SHOWZERO        5
-    { "showzero", 0 },
-#define NOSHOWZERO      6
-    { "noshowzero", 0 },
-#define ALPHASW         7
-    { "alpha", 0 },
-#define NOALPHASW       8
-    { "noalpha", 0 },
-#define FASTSW          9
-    { "fast", 0 },
-#define NOFASTSW        10
-    { "nofast", 0 },
-#define TOTALSW         11
-    { "total", -5 },
-#define NOTOTALSW       12
-    { "nototal", -7 },
-#define VERSIONSW      13
-    { "version", 0 },
-#define HELPSW          14
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FLIST_SWITCHES \
+    X("sequence name", 0, SEQSW) \
+    X("all", 0, ALLSW) \
+    X("noall", 0, NOALLSW) \
+    X("recurse", 0, RECURSE) \
+    X("norecurse", 0, NORECURSE) \
+    X("showzero", 0, SHOWZERO) \
+    X("noshowzero", 0, NOSHOWZERO) \
+    X("alpha", 0, ALPHASW) \
+    X("noalpha", 0, NOALPHASW) \
+    X("fast", 0, FASTSW) \
+    X("nofast", 0, NOFASTSW) \
+    X("total", -5, TOTALSW) \
+    X("nototal", -7, NOTOTALSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FLIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FLIST, switches);
+#undef X
 
 struct Folder {
     char *name;                        /* name of folder */
index 783aa96e96f326cc16f1734d36f3583178fa25c6..653581684c1c87f82aeafa0a7fbe8f2114e87cad 100644 (file)
 #include <h/fmt_compile.h>
 #include <h/scansbr.h>
 
-static struct swit switches[] = {
-#define        FORMSW              0
-    { "form formatfile", 0 },
-#define        FMTSW               1
-    { "format string", 5 },
-#define VERSIONSW           2
-    { "version", 0 },
-#define        HELPSW              3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FMTDUMP_SWITCHES \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FMTDUMP);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FMTDUMP, switches);
+#undef X
 
 /* for assignlabel */
 static struct format *lvec[128];
index 4f43b9fc56b639a0225cb36f68307b3186249a6b..e4defc70552a79d3318b5a73442019b2701e1e27 100644 (file)
 #include <h/utils.h>
 #include <errno.h>
 
-static struct swit switches[] = {
-#define        ALLSW           0
-    { "all", 0 },
-#define NALLSW         1
-    { "noall", 0 },
-#define        CREATSW         2
-    { "create", 0 },
-#define        NCREATSW        3
-    { "nocreate", 0 },
-#define        FASTSW          4
-    { "fast", 0 },
-#define        NFASTSW         5
-    { "nofast", 0 },
-#define        HDRSW           6
-    { "header", 0 },
-#define        NHDRSW          7
-    { "noheader", 0 },
-#define        PACKSW          8
-    { "pack", 0 },
-#define        NPACKSW         9
-    { "nopack", 0 },
-#define        VERBSW         10
-    { "verbose", 0 },
-#define        NVERBSW        11
-    { "noverbose", 0 },
-#define        RECURSW        12
-    { "recurse", 0 },
-#define        NRECRSW        13
-    { "norecurse", 0 },
-#define        TOTALSW        14
-    { "total", 0 },
-#define        NTOTLSW        15
-    { "nototal", 0 },
-#define        LISTSW         16
-    { "list", 0 },
-#define        NLISTSW        17
-    { "nolist", 0 },
-#define        PRNTSW         18
-    { "print", 0 },
-#define        NPRNTSW        19
-    { "noprint", -4 },
-#define        PUSHSW         20
-    { "push", 0 },
-#define        POPSW          21
-    { "pop", 0 },
-#define VERSIONSW      22
-    { "version", 0 },
-#define        HELPSW         23
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FOLDER_SWITCHES \
+    X("all", 0, ALLSW) \
+    X("noall", 0, NALLSW) \
+    X("create", 0, CREATSW) \
+    X("nocreate", 0, NCREATSW) \
+    X("fast", 0, FASTSW) \
+    X("nofast", 0, NFASTSW) \
+    X("header", 0, HDRSW) \
+    X("noheader", 0, NHDRSW) \
+    X("pack", 0, PACKSW) \
+    X("nopack", 0, NPACKSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("recurse", 0, RECURSW) \
+    X("norecurse", 0, NRECRSW) \
+    X("total", 0, TOTALSW) \
+    X("nototal", 0, NTOTLSW) \
+    X("list", 0, LISTSW) \
+    X("nolist", 0, NLISTSW) \
+    X("print", 0, PRNTSW) \
+    X("noprint", -4, NPRNTSW) \
+    X("push", 0, PUSHSW) \
+    X("pop", 0, POPSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FOLDER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FOLDER, switches);
+#undef X
 
 static int fshort   = 0;       /* output only folder names                 */
 static int fcreat   = 0;       /* should we ask to create new folders?     */
index 2d6709e8fd5c6c9e4064e55e256367ac7549ee1f..58c613092e1b917c8fea7d25fd2151bdbdce33ec 100644 (file)
 #define        IFORMAT "digest-issue-%s"
 #define        VFORMAT "digest-volume-%s"
 
-static struct swit switches[] = {
-#define        ANNOSW                 0
-    { "annotate", 0 },
-#define        NANNOSW                1
-    { "noannotate", 0 },
-#define        DFOLDSW                2
-    { "draftfolder +folder", 0 },
-#define        DMSGSW                 3
-    { "draftmessage msg", 0 },
-#define        NDFLDSW                4
-    { "nodraftfolder", 0 },
-#define        EDITRSW                5
-    { "editor editor", 0 },
-#define        NEDITSW                6
-    { "noedit", 0 },
-#define        FILTSW                 7
-    { "filter filterfile", 0 },
-#define        FORMSW                 8
-    { "form formfile", 0 },
-#define        FRMTSW                 9
-    { "format", 5 },
-#define        NFRMTSW               10
-    { "noformat", 7 },
-#define        INPLSW                11
-    { "inplace", 0 },
-#define        NINPLSW               12
-    { "noinplace", 0 },
-#define MIMESW                13
-    { "mime", 0 },
-#define NMIMESW               14
-    { "nomime", 0 },
-#define        DGSTSW                15
-    { "digest list", 0 },
-#define        ISSUESW               16
-    { "issue number", 0 },
-#define        VOLUMSW               17
-    { "volume number", 0 },
-#define        WHATSW                18
-    { "whatnowproc program", 0 },
-#define        NWHATSW               19
-    { "nowhatnowproc", 0 },
-#define        BITSTUFFSW            20
-    { "dashstuffing", 0 },             /* interface to mhl */
-#define        NBITSTUFFSW           21
-    { "nodashstuffing", 0 },
-#define VERSIONSW             22
-    { "version", 0 },
-#define        HELPSW                23
-    { "help", 0 },
-#define        FILESW                24
-    { "file file", 4 },                        /* interface from msh */
-#define        BILDSW                25
-    { "build", 5 },                    /* interface from mhe */
-#define FROMSW                26
-    { "from address", 0 },
-#define TOSW                  27
-    { "to address", 0 },
-#define CCSW                  28
-    { "cc address", 0 },
-#define SUBJECTSW             29
-    { "subject text", 0 },
-#define FCCSW                 30
-    { "fcc mailbox", 0 },
-#define WIDTHSW               31
-    { "width columns", 0 },
-    { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define        NOSW         0
-    { "quit", 0 },
-#define        YESW         1
-    { "replace", 0 },
-#define        LISTDSW      2
-    { "list", 0 },
-#define        REFILSW      3
-    { "refile +folder", 0 },
-#define NEWSW        4
-    { "new", 0 },
-    { NULL, 0 }
-};
+#define FORW_SWITCHES \
+    X("annotate", 0, ANNOSW) \
+    X("noannotate", 0, NANNOSW) \
+    X("draftfolder +folder", 0, DFOLDSW) \
+    X("draftmessage msg", 0, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("editor editor", 0, EDITRSW) \
+    X("noedit", 0, NEDITSW) \
+    X("filter filterfile", 0, FILTSW) \
+    X("form formfile", 0, FORMSW) \
+    X("format", 5, FRMTSW) \
+    X("noformat", 7, NFRMTSW) \
+    X("inplace", 0, INPLSW) \
+    X("noinplace", 0, NINPLSW) \
+    X("mime", 0, MIMESW) \
+    X("nomime", 0, NMIMESW) \
+    X("digest list", 0, DGSTSW) \
+    X("issue number", 0, ISSUESW) \
+    X("volume number", 0, VOLUMSW) \
+    X("whatnowproc program", 0, WHATSW) \
+    X("nowhatnowproc", 0, NWHATSW) \
+    X("dashstuffing", 0, BITSTUFFSW)          /* interface to mhl */ \
+    X("nodashstuffing", 0, NBITSTUFFSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("file file", 4, FILESW)                 /* interface from msh */ \
+    X("build", 5, BILDSW)                     /* interface from mhe */ \
+    X("from address", 0, FROMSW) \
+    X("to address", 0, TOSW) \
+    X("cc address", 0, CCSW) \
+    X("subject text", 0, SUBJECTSW) \
+    X("fcc mailbox", 0, FCCSW) \
+    X("width columns", 0, WIDTHSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FORW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FORW, switches);
+#undef X
+
+#define DISPO_SWITCHES \
+    X("quit", 0, NOSW) \
+    X("replace", 0, YESW) \
+    X("list", 0, LISTDSW) \
+    X("refile +folder", 0, REFILSW) \
+    X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
 
 static struct swit aqrl[] = {
-    { "quit", 0 },
-    { "replace", 0 },
-    { "list", 0 },
-    { "refile +folder", 0 },
+    { "quit", 0, NOSW },
+    { "replace", 0, YESW },
+    { "list", 0, LISTDSW },
+    { "refile +folder", 0, REFILSW },
     { NULL, 0 }
 };
 
index 07440b123f3cd5e56f668dc28abcbbd45ba5c0dd..3ec47fae6dfbb0857f67759d2d80be73da0fb649 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
 # define SASLminc(a)  0
 #endif
 
-static struct swit switches[] = {
-#define        AUDSW                      0
-    { "audit audit-file", 0 },
-#define        NAUDSW                     1
-    { "noaudit", 0 },
-#define        CHGSW                      2
-    { "changecur", 0 },
-#define        NCHGSW                     3
-    { "nochangecur", 0 },
-#define        FILESW                     4
-    { "file name", 0 },
-#define        FORMSW                     5
-    { "form formatfile", 0 },
-#define        FMTSW                      6
-    { "format string", 5 },
-#define        HOSTSW                     7
-    { "host hostname", 0 },
-#define        USERSW                     8
-    { "user username", 0 },
-#define        PACKSW                     9
-    { "pack file", 0},
-#define        NPACKSW                   10
-    { "nopack", 0 },
-#define PORTSW                   11
-    { "port name/number", 0 },
-#define        SILSW                     12
-    { "silent", 0 },
-#define        NSILSW                    13
-    { "nosilent", 0 },
-#define        TRNCSW                    14
-    { "truncate", 0 },
-#define        NTRNCSW                   15
-    { "notruncate", 0 },
-#define        WIDTHSW                   16
-    { "width columns", 0 },
-#define VERSIONSW                 17
-    { "version", 0 },
-#define        HELPSW                    18
-    { "help", 0 },
-#define SNOOPSW                   19
-    { "snoop", -5 },
-#define SASLSW                    20
-    { "sasl", SASLminc(-4) },
-#define NOSASLSW                  21
-    { "nosasl", SASLminc(-6) },
-#define SASLMECHSW                22
-    { "saslmech", SASLminc(-8) },
-#define PROXYSW                   23
-    { "proxy command", 0 },
-    { NULL, 0 }
-};
+#define INC_SWITCHES \
+    X("audit audit-file", 0, AUDSW) \
+    X("noaudit", 0, NAUDSW) \
+    X("changecur", 0, CHGSW) \
+    X("nochangecur", 0, NCHGSW) \
+    X("file name", 0, FILESW) \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("host hostname", 0, HOSTSW) \
+    X("user username", 0, USERSW) \
+    X("pack file", 0, PACKSW) \
+    X("nopack", 0, NPACKSW) \
+    X("port name/number", 0, PORTSW) \
+    X("silent", 0, SILSW) \
+    X("nosilent", 0, NSILSW) \
+    X("truncate", 0, TRNCSW) \
+    X("notruncate", 0, NTRNCSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("snoop", -5, SNOOPSW) \
+    X("sasl", SASLminc(-4), SASLSW) \
+    X("nosasl", SASLminc(-6), NOSASLSW) \
+    X("saslmech", SASLminc(-8), SASLMECHSW) \
+    X("proxy command", 0, PROXYSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(INC);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(INC, switches);
+#undef X
 
 /*
  * flags for the mail source
index 2cf9081c7a78b03675df212a2219abecb21dc538..2921d2619ccc0bd74f2f9e285ae4e08da05c8ce9 100644 (file)
 #include <h/utils.h>
 #include <pwd.h>                               /* structure for getpwuid() results */
 
-static struct swit switches[] = {
-#define AUTOSW     0
-    { "auto", 0 },
-#define VERSIONSW  1
-    { "version", 0 },
-#define HELPSW     2
-    { "help", 0 },
-#define CHECKSW     3
-    { "check", 1 },
-    { NULL, 0 }
-};
+#define INSTALLMH_SWITCHES \
+    X("auto", 0, AUTOSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("check", 1, CHECKSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(INSTALLMH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(INSTALLMH, switches);
+#undef X
 
 /*
  * static prototypes
index 22a12ee3588aa7282ff4482af37a7d97dc82dff9..f99832a2c76847fa64ad7b38aea5909b5d191dd2 100644 (file)
 #include <h/mh.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        ADDSW               0
-    { "add", 0 },
-#define        DELSW               1
-    { "delete", 0 },
-#define        LSTSW               2
-    { "list", 0 },
-#define        SEQSW               3
-    { "sequence name", 0 },
-#define        PUBLSW              4
-    { "public", 0 },
-#define        NPUBLSW             5
-    { "nopublic", 0 },
-#define        ZEROSW              6
-    { "zero", 0 },
-#define        NZEROSW             7
-    { "nozero", 0 },
-#define VERSIONSW           8
-    { "version", 0 },
-#define        HELPSW              9
-    { "help", 0 },
-#define        DEBUGSW            10
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MARK_SWITCHES \
+    X("add", 0, ADDSW) \
+    X("delete", 0, DELSW) \
+    X("list", 0, LSTSW) \
+    X("sequence name", 0, SEQSW) \
+    X("public", 0, PUBLSW) \
+    X("nopublic", 0, NPUBLSW) \
+    X("zero", 0, ZEROSW) \
+    X("nozero", 0, NZEROSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MARK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MARK, switches);
+#undef X
 
 /*
  * static prototypes
index 1fdeb6f91681e6da6cbeb35a830573347ecda0b8..893ef8d644e09e640591fd664ff2e33856d593a0 100644 (file)
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        CHECKSW                 0
-    { "check", 0 },
-#define        NCHECKSW                1
-    { "nocheck", 0 },
-#define        DIRECTIVES              2
-    { "directives", 0 },
-#define        NDIRECTIVES             3
-    { "nodirectives", 0 },
-#define        HEADSW                  4
-    { "headers", 0 },
-#define        NHEADSW                 5
-    { "noheaders", 0 },
-#define        LISTSW                  6
-    { "list", 0 },
-#define        NLISTSW                 7
-    { "nolist", 0 },
-#define        SIZESW                  8
-    { "realsize", 0 },
-#define        NSIZESW                 9
-    { "norealsize", 0 },
-#define        RFC934SW               10
-    { "rfc934mode", 0 },
-#define        NRFC934SW              11
-    { "norfc934mode", 0 },
-#define        VERBSW                 12
-    { "verbose", 0 },
-#define        NVERBSW                13
-    { "noverbose", 0 },
-#define        RCACHESW               14
-    { "rcache policy", 0 },
-#define        WCACHESW               15
-    { "wcache policy", 0 },
-#define        CONTENTIDSW            16
-    { "contentid", 0 },
-#define        NCONTENTIDSW           17
-    { "nocontentid", 0 },
-#define VERSIONSW              18
-    { "version", 0 },
-#define        HELPSW                 19
-    { "help", 0 },
-#define        DEBUGSW                20
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MHBUILD_SWITCHES \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("directives", 0, DIRECTIVES) \
+    X("nodirectives", 0, NDIRECTIVES) \
+    X("headers", 0, HEADSW) \
+    X("noheaders", 0, NHEADSW) \
+    X("list", 0, LISTSW) \
+    X("nolist", 0, NLISTSW) \
+    X("realsize", 0, SIZESW) \
+    X("norealsize", 0, NSIZESW) \
+    X("rfc934mode", 0, RFC934SW) \
+    X("norfc934mode", 0, NRFC934SW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("contentid", 0, CONTENTIDSW) \
+    X("nocontentid", 0, NCONTENTIDSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHBUILD);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHBUILD, switches);
+#undef X
 
 
 /* mhbuildsbr.c */
index 021a4b202ff9194728abe1add4fa2b7792f8cbb9..1363081c39b0edc6cdd0df389953467906ab1cd4 100644 (file)
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        CHECKSW                 0
-    { "check", 0 },
-#define        NCHECKSW                1
-    { "nocheck", 0 },
-#define        HEADSW                  2
-    { "headers", 0 },
-#define        NHEADSW                 3
-    { "noheaders", 0 },
-#define        SIZESW                  4
-    { "realsize", 0 },
-#define        NSIZESW                 5
-    { "norealsize", 0 },
-#define        VERBSW                  6
-    { "verbose", 0 },
-#define        NVERBSW                 7
-    { "noverbose", 0 },
-#define        FILESW                  8       /* interface from show */
-    { "file file", 0 },
-#define        PARTSW                  9
-    { "part number", 0 },
-#define        TYPESW                 10
-    { "type content", 0 },
-#define        RCACHESW               11
-    { "rcache policy", 0 },
-#define        WCACHESW               12
-    { "wcache policy", 0 },
-#define VERSIONSW              13
-    { "version", 0 },
-#define        HELPSW                 14
-    { "help", 0 },
-
-/*
- * switches for debugging
- */
-#define        DEBUGSW                15
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MHLIST_SWITCHES \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("headers", 0, HEADSW) \
+    X("noheaders", 0, NHEADSW) \
+    X("realsize", 0, SIZESW) \
+    X("norealsize", 0, NSIZESW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("file file", 0, FILESW) \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHLIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHLIST, switches);
+#undef X
 
 
 /* mhparse.c */
index 45d99b037d1f1e585d34187dfd881ce2c7ac6661..e0759334111f94af88db846871ca698f2bed5542 100644 (file)
 
 #define        QUOTE   '\\'
 
-static struct swit mhlswitches[] = {
-#define        BELLSW         0
-    { "bell", 0 },
-#define        NBELLSW        1
-    { "nobell", 0 },
-#define        CLRSW          2
-    { "clear", 0 },
-#define        NCLRSW         3
-    { "noclear", 0 },
-#define        FOLDSW         4
-    { "folder +folder", 0 },
-#define        FORMSW         5
-    { "form formfile", 0 },
-#define        PROGSW         6
-    { "moreproc program", 0 },
-#define        NPROGSW        7
-    { "nomoreproc", 0 },
-#define        LENSW          8
-    { "length lines", 0 },
-#define        WIDTHSW        9
-    { "width columns", 0 },
-#define        SLEEPSW       10
-    { "sleep seconds",  0 },
-#define        BITSTUFFSW    11
-    { "dashstuffing", -12 },   /* interface from forw */
-#define        NBITSTUFFSW   12
-    { "nodashstuffing", -14 }, /* interface from forw */
-#define VERSIONSW     13
-    { "version", 0 },
-#define        HELPSW        14
-    { "help", 0 },
-#define        FORW1SW       15
-    { "forward", -7 },         /* interface from forw */
-#define        FORW2SW       16
-    { "forwall", -7 },         /* interface from forw */
-#define        DGSTSW        17
-    { "digest list", -6 },
-#define VOLUMSW       18
-    { "volume number", -6 },
-#define ISSUESW       19
-    { "issue number", -5 },
-#define NBODYSW       20
-    { "nobody", -6 },
-#define FMTPROCSW     21
-    { "fmtproc program", 0 },
-#define NFMTPROCSW    22
-    { "nofmtproc", 0 },
-    { NULL, 0 }
-};
+#define MHL_SWITCHES \
+    X("bell", 0, BELLSW) \
+    X("nobell", 0, NBELLSW) \
+    X("clear", 0, CLRSW) \
+    X("noclear", 0, NCLRSW) \
+    X("folder +folder", 0, FOLDSW) \
+    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("sleep seconds", 0, SLEEPSW) \
+    X("dashstuffing", -12, BITSTUFFSW)    /* interface from forw */ \
+    X("nodashstuffing", -14, NBITSTUFFSW) /* interface from forw */ \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("forward", -7, FORW1SW)             /* interface from forw */ \
+    X("forwall", -7, FORW2SW)             /* interface from forw */ \
+    X("digest list", -6, DGSTSW) \
+    X("volume number", -6, VOLUMSW) \
+    X("issue number", -5, ISSUESW) \
+    X("nobody", -6, NBODYSW) \
+    X("fmtproc program", 0, FMTPROCSW) \
+    X("nofmtproc", 0, NFMTPROCSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHL, mhlswitches);
+#undef X
 
 #define NOCOMPONENT 0x000001   /* don't show component name         */
 #define UPPERCASE   0x000002   /* display in all upper case         */
index aab681f2438f4d3b7dac36826bea8caebff7bfc2..5ce762227bc738801950b6395779f945a348dd7d 100644 (file)
--- a/uip/mhn.c
+++ b/uip/mhn.c
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        AUTOSW                  0
-    { "auto", 0 },
-#define        NAUTOSW                 1
-    { "noauto", 0 },
-#define        CACHESW                 2
-    { "cache", 0 },
-#define        NCACHESW                3
-    { "nocache", 0 },
-#define        CHECKSW                 4
-    { "check", 0 },
-#define        NCHECKSW                5
-    { "nocheck", 0 },
-#define        HEADSW                  6
-    { "headers", 0 },
-#define        NHEADSW                 7
-    { "noheaders", 0 },
-#define        LISTSW                  8
-    { "list", 0 },
-#define        NLISTSW                 9
-    { "nolist", 0 },
-#define        PAUSESW                10
-    { "pause", 0 },
-#define        NPAUSESW               11
-    { "nopause", 0 },
-#define        SIZESW                 12
-    { "realsize", 0 },
-#define        NSIZESW                13
-    { "norealsize", 0 },
-#define        SERIALSW               14
-    { "serialonly", 0 },
-#define        NSERIALSW              15
-    { "noserialonly", 0 },
-#define        SHOWSW                 16
-    { "show", 0 },
-#define        NSHOWSW                17
-    { "noshow", 0 },
-#define        STORESW                18
-    { "store", 0 },
-#define        NSTORESW               19
-    { "nostore", 0 },
-#define        VERBSW                 20
-    { "verbose", 0 },
-#define        NVERBSW                21
-    { "noverbose", 0 },
-#define        FILESW                 22       /* interface from show */
-    { "file file", 0 },
-#define        FORMSW                 23
-    { "form formfile", 0 },
-#define        PARTSW                 24
-    { "part number", 0 },
-#define        TYPESW                 25
-    { "type content", 0 },
-#define        RCACHESW               26
-    { "rcache policy", 0 },
-#define        WCACHESW               27
-    { "wcache policy", 0 },
-#define VERSIONSW              28
-    { "version", 0 },
-#define        HELPSW                 29
-    { "help", 0 },
-
-/*
- * switches for debugging
- */
-#define        DEBUGSW                30
-    { "debug", -5 },
-
-/*
- * switches for moreproc/mhlproc
- */
-#define        PROGSW                 31
-    { "moreproc program", -4 },
-#define        NPROGSW                32
-    { "nomoreproc", -3 },
-#define        LENSW                  33
-    { "length lines", -4 },
-#define        WIDTHSW                34
-    { "width columns", -4 },
-
-/*
- * switches for mhbuild
- */
-#define BUILDSW                35
-    { "build", -5 },
-#define NBUILDSW               36
-    { "nobuild", -7 },
-#define        RFC934SW               37
-    { "rfc934mode", -10 },
-#define        NRFC934SW              38
-    { "norfc934mode", -12 },
-    { NULL, 0 }
-};
+#define MHN_SWITCHES \
+    X("auto", 0, AUTOSW) \
+    X("noauto", 0, NAUTOSW) \
+    X("cache", 0, CACHESW) \
+    X("nocache", 0, NCACHESW) \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("headers", 0, HEADSW) \
+    X("noheaders", 0, NHEADSW) \
+    X("list", 0, LISTSW) \
+    X("nolist", 0, NLISTSW) \
+    X("pause", 0, PAUSESW) \
+    X("nopause", 0, NPAUSESW) \
+    X("realsize", 0, SIZESW) \
+    X("norealsize", 0, NSIZESW) \
+    X("serialonly", 0, SERIALSW) \
+    X("noserialonly", 0, NSERIALSW) \
+    X("show", 0, SHOWSW) \
+    X("noshow", 0, NSHOWSW) \
+    X("store", 0, STORESW) \
+    X("nostore", 0, NSTORESW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("file file", 0, FILESW) \
+    X("form formfile", 0, FORMSW) \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    /*                                 \
+     * for debugging                   \
+     */                                        \
+    X("debug", -5, DEBUGSW) \
+    /*                                 \
+     * switches for moreproc/mhlproc   \
+     */                                        \
+    X("moreproc program", -4, PROGSW) \
+    X("nomoreproc", -3, NPROGSW) \
+    X("length lines", -4, LENSW) \
+    X("width columns", -4, WIDTHSW) \
+    /*                                 \
+     * switches for mhbuild            \
+     */                                        \
+    X("build", -5, BUILDSW) \
+    X("nobuild", -7, NBUILDSW) \
+    X("rfc934mode", -10, RFC934SW) \
+    X("norfc934mode", -12, NRFC934SW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHN, switches);
+#undef X
 
 
 /* mhparse.c */
index d2603522f858a5f9bb497280773c178a5ffb8657..1fb50a724d41d9e57592fa68db7dccc0c7e67e35 100644 (file)
@@ -17,21 +17,21 @@ extern char *mhetcdir;
 
 char *sbackup = BACKUP_PREFIX;
 
-static struct swit switches[] = {
-#define        COMPSW    0
-    { "components", 0 },
-#define        NCOMPSW   1
-    { "nocomponents", 0 },
-#define        ALLSW     2
-    { "all", 0 },
-#define VERSIONSW 3
-    { "version", 0 },
-#define        HELPSW    4
-    { "help", 0 },
-#define DEBUGSW   5
-    { "debug", 5 },
-    { NULL, 0 }
-};
+#define MHPARAM_SWITCHES \
+    X("components", 0, COMPSW) \
+    X("nocomponents", 0, NCOMPSW) \
+    X("all", 0, ALLSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", 5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHPARAM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHPARAM, switches);
+#undef X
 
 struct proc {
     char *p_name;
index bb77996cfa4456bc612bf10b75743c2caff4ddd4..ef16bce2025c1b72358e024e81b5ba2884d88799 100644 (file)
 #include <h/mh.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define VERSIONSW 0
-    { "version", 0 },
-#define        HELPSW  1
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define MHPATH_SWITCHES \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHPATH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHPATH, switches);
+#undef X
 
 int
 main(int argc, char **argv)
index 993477bb6c8e23b9cc97de7925c70440e933d760..8e1a9003f7fd22da26d32c5ac4d33945c51a5106 100644 (file)
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        CHECKSW                 0
-    { "check", 0 },
-#define        NCHECKSW                1
-    { "nocheck", 0 },
-#define        PAUSESW                 2
-    { "pause", 0 },
-#define        NPAUSESW                3
-    { "nopause", 0 },
-#define        SERIALSW                4
-    { "serialonly", 0 },
-#define        NSERIALSW               5
-    { "noserialonly", 0 },
-#define        VERBSW                  6
-    { "verbose", 0 },
-#define        NVERBSW                 7
-    { "noverbose", 0 },
-#define        FILESW                  8       /* interface from show */
-    { "file file", 0 },
-#define        FORMSW                  9
-    { "form formfile", 0 },
-#define        PARTSW                 10
-    { "part number", 0 },
-#define        TYPESW                 11
-    { "type content", 0 },
-#define        RCACHESW               12
-    { "rcache policy", 0 },
-#define        WCACHESW               13
-    { "wcache policy", 0 },
-#define VERSIONSW              14
-    { "version", 0 },
-#define        HELPSW                 15
-    { "help", 0 },
-
-/*
- * switches for moreproc/mhlproc
- */
-#define        PROGSW                 16
-    { "moreproc program", -4 },
-#define        NPROGSW                17
-    { "nomoreproc", -3 },
-#define        LENSW                  18
-    { "length lines", -4 },
-#define        WIDTHSW                19
-    { "width columns", -4 },
-
-/*
- * switches for debugging
- */
-#define        DEBUGSW                20
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MHSHOW_SWITCHES \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("pause", 0, PAUSESW) \
+    X("nopause", 0, NPAUSESW) \
+    X("serialonly", 0, SERIALSW) \
+    X("noserialonly", 0, NSERIALSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("file file", 0, FILESW) \
+    X("form formfile", 0, FORMSW) \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    /*                                 \
+     * switches for moreproc/mhlproc   \
+     */                                        \
+    X("moreproc program", -4, PROGSW) \
+    X("nomoreproc", -3, NPROGSW) \
+    X("length lines", -4, LENSW) \
+    X("width columns", -4, WIDTHSW) \
+    /*                         \
+     * switches for debugging  \
+     */                                \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHSHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHSHOW, switches);
+#undef X
 
 
 /* mhparse.c */
index fa30e035fa24c24ce84d4cf2b58dba1f16df2c40..61a54e631a04daefea38ca460af7f16dcda35d52 100644 (file)
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        AUTOSW                  0
-    { "auto", 0 },
-#define        NAUTOSW                 1
-    { "noauto", 0 },
-#define        CHECKSW                 2
-    { "check", 0 },
-#define        NCHECKSW                3
-    { "nocheck", 0 },
-#define        VERBSW                  4
-    { "verbose", 0 },
-#define        NVERBSW                 5
-    { "noverbose", 0 },
-#define        FILESW                  6       /* interface from show */
-    { "file file", 0 },
-#define        PARTSW                  7
-    { "part number", 0 },
-#define        TYPESW                  8
-    { "type content", 0 },
-#define        RCACHESW                9
-    { "rcache policy", 0 },
-#define        WCACHESW               10
-    { "wcache policy", 0 },
-#define VERSIONSW              11
-    { "version", 0 },
-#define        HELPSW                 12
-    { "help", 0 },
-#define        CLOBBERSW              13
-    { "clobber always|auto|suffix|ask|never", 0 },
-
-/*
- * switches for debugging
- */
-#define        DEBUGSW                14
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MHSTORE_SWITCHES \
+    X("auto", 0, AUTOSW) \
+    X("noauto", 0, NAUTOSW) \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("file file", 0, FILESW)          /* interface from show */ \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("clobber always|auto|suffix|ask|never", 0, CLOBBERSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHSTORE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHSTORE, switches);
+#undef X
 
 
 int save_clobber_policy (const char *);
index ca03bda8677dd4e62da40e4399d8de2fc4420efb..b978dbfb3c304f7c262dc4f50aa9f6c9b9c7a4f4 100644 (file)
@@ -1228,7 +1228,7 @@ clobber_check (char *original_file) {
         if (stat (file, &st) == OK) {
           enum answers { NMH_YES, NMH_NO, NMH_RENAME };
           static struct swit answer[4] = {
-            { "yes", 0 }, { "no", 0 }, { "rename", 0 }, { NULL, 0 } };
+            { "yes", 0, NMH_YES }, { "no", 0, NMH_NO }, { "rename", 0, NMH_RENAME }, { NULL, 0, 0 } };
           char **ans;
 
           if (isatty (fileno (stdin))) {
index fda60f7764d500ee4bced9c0105980febda03e5b..44cc3b23b7930aa4f370000723da8213bf88435d 100644 (file)
 #include <h/mhcachesbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        CHECKSW                 0
-    { "check", 0 },
-#define        NCHECKSW                1
-    { "nocheck", 0 },
-#define        VERBSW                  2
-    { "verbose", 0 },
-#define        NVERBSW                 3
-    { "noverbose", 0 },
-#define        FILESW                  4
-    { "file file", 0 },
-#define OUTFILESW               5
-    { "outfile file", 0 },
-#define        PARTSW                  6
-    { "part number", 0 },
-#define        TYPESW                  7
-    { "type content", 0 },
-#define        RCACHESW                8
-    { "rcache policy", 0 },
-#define        WCACHESW                9
-    { "wcache policy", 0 },
-#define VERSIONSW              10
-    { "version", 0 },
-#define        HELPSW                 11
-    { "help", 0 },
-
-/*
- * switches for debugging
- */
-#define        DEBUGSW                12
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MHTEST_SWITCHES \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("file file", 0, FILESW) \
+    X("outfile file", 0, OUTFILESW) \
+    X("part number", 0, PARTSW) \
+    X("type content", 0, TYPESW) \
+    X("rcache policy", 0, RCACHESW) \
+    X("wcache policy", 0, WCACHESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHTEST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHTEST, switches);
+#undef X
 
 
 /* mhparse.c */
index 3654995b381516df80e5b3e535d2480fe6a563d4..6a0a12e7940f7b094ff790bcc7e42ff0306093b8 100644 (file)
 # define SASLminc(a)  0
 #endif
 
-static struct swit switches[] = {
-#define        DATESW                   0
-    { "date", 0 },
-#define        NDATESW                  1
-    { "nodate", 0 },
-#define        NOTESW                   2
-    { "notify type", 0 },
-#define        NNOTESW                  3
-    { "nonotify type", 0 },
-#define        HOSTSW                   4
-    { "host hostname", 0 },
-#define        USERSW                   5
-    { "user username", 0 },
-#define PORTSW                  6
-    { "port name/number", 0 },
-#define VERSIONSW                7
-    { "version", 0 },
-#define        HELPSW                   8
-    { "help", 0 },
-#define SNOOPSW                  9
-    { "snoop", -5 },
-#define SASLSW                  10
-    { "sasl", SASLminc(-4) },
-#define SASLMECHSW             11
-    { "saslmech", SASLminc(-5) },
-#define PROXYSW                12
-    { "proxy command", 0 },
-    { NULL, 0 }
-};
+#define MSGCHK_SWITCHES \
+    X("date", 0, DATESW) \
+    X("nodate", 0, NDATESW) \
+    X("notify type", 0, NOTESW) \
+    X("nonotify type", 0, NNOTESW) \
+    X("host hostname", 0, HOSTSW) \
+    X("user username", 0, USERSW) \
+    X("port name/number", 0, PORTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("snoop", -5, SNOOPSW) \
+    X("sasl", SASLminc(-4), SASLSW) \
+    X("saslmech", SASLminc(-5), SASLMECHSW) \
+    X("proxy command", 0, PROXYSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSGCHK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSGCHK, switches);
+#undef X
 
 /*
  * Maximum numbers of users we can check (plus
@@ -240,15 +233,18 @@ main (int argc, char **argv)
 }
 
 
-static struct swit ntswitches[] = {
-#define        NALLSW     0
-    { "all", 0 },
-#define        NMAISW     1
-    { "mail", 0 },
-#define        NNMAISW    2
-    { "nomail", 0 },
-    { NULL, 0 }
-};
+#define NOTE_SWITCHES \
+    X("all", 0, NALLSW) \
+    X("mail", 0, NMAISW) \
+    X("nomail", 0, NNMAISW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(NOTE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(NOTE, ntswitches);
+#undef X
 
 
 static int
index b3aa3a107aec077ce57472d8c129851b197ccdca..6069cac44c4e20dc88666b22bd1529a066b4e8b6 100644 (file)
--- a/uip/msh.c
+++ b/uip/msh.c
 
 #define        QUOTE   '\\'            /* sigh */
 
-static struct swit switches[] = {
-#define        IDSW                  0
-    { "idstart number", -7 },          /* interface from bbc */
-#define        FDSW                  1
-    { "idstop number", -6 },           /*  .. */
-#define        QDSW                  2
-    { "idquit number", -6 },           /*  .. */
-#define        NMSW                  3
-    { "idname BBoard", -6 },           /*  .. */
-#define        PRMPTSW               4
-    { "prompt string", 0 },
-#define        SCANSW                5
-    { "scan", 0 },
-#define        NSCANSW               6
-    { "noscan", 0 },
-#define        READSW                7
-    { "vmhread fd", -7 },
-#define        WRITESW               8
-    { "vmhwrite fd", -8 },     
-#define        PREADSW               9
-    { "popread fd", -7 },
-#define        PWRITSW              10
-    { "popwrite fd", -8 },
-#define        TCURSW               11
-    { "topcur", 0 },
-#define        NTCURSW              12
-    { "notopcur", 0 },
-#define VERSIONSW            13
-    { "version", 0 },
-#define        HELPSW               14
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define MSH_SWITCHES \
+    X("idstart number", -7, IDSW) /* interface from bbc */ \
+    X("idstop number", -6, FDSW) /*  .. */ \
+    X("idquit number", -6, QDSW) /*  .. */ \
+    X("idname BBoard", -6, NMSW) /*  .. */ \
+    X("prompt string", 0, PRMPTSW) \
+    X("scan", 0, SCANSW) \
+    X("noscan", 0, NSCANSW) \
+    X("vmhread fd", -7, READSW) \
+    X("vmhwrite fd", -8, WRITESW) \
+    X("popread fd", -7, PREADSW) \
+    X("popwrite fd", -8, PWRITSW) \
+    X("topcur", 0, TCURSW) \
+    X("notopcur", 0, NTCURSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSH);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSH, switches);
+#undef X
 
 static int mbx_style = MMDF_FORMAT;
 
@@ -358,65 +349,43 @@ main (int argc, char **argv)
 }
 
 
-static struct swit mshcmds[] = {
-#define        ADVCMD  0
-    { "advance", -7 },
-#define        ALICMD  1
-    { "ali", 0 },
-#define        EXPLCMD 2
-    { "burst", 0 },
-#define        COMPCMD 3
-    { "comp", 0 },
-#define        DISTCMD 4
-    { "dist", 0 },
-#define        EXITCMD 5
-    { "exit", 0 },
-#define        FOLDCMD 6
-    { "folder", 0 },
-#define        FORWCMD 7
-    { "forw", 0 },
-#define        HELPCMD 8
-    { "help", 0 },
-#define        INCMD   9
-    { "inc", 0 },
-#define        MARKCMD 10
-    { "mark", 0 },
-#define        MAILCMD 11
-    { "mhmail", 0 },
-#define        MHNCMD  12
-    { "mhn", 0 },
-#define        MSGKCMD 13
-    { "msgchk", 0 },
-#define        NEXTCMD 14
-    { "next", 0 },
-#define        PACKCMD 15
-    { "packf", 0 },
-#define        PICKCMD 16
-    { "pick", 0 },
-#define        PREVCMD 17
-    { "prev", 0 },
-#define        QUITCMD 18
-    { "quit", 0 },
-#define        FILECMD 19
-    { "refile", 0 },
-#define        REPLCMD 20
-    { "repl", 0 },
-#define        RMMCMD  21
-    { "rmm", 0 },
-#define        SCANCMD 22
-    { "scan", 0 },
-#define        SENDCMD 23
-    { "send", 0 },
-#define        SHOWCMD 24
-    { "show", 0 },
-#define        SORTCMD 25
-    { "sortm", 0 },
-#define        WHATCMD 26
-    { "whatnow", 0 },
-#define        WHOMCMD 27
-    { "whom", 0 },
-    { NULL, 0 }
-};
+#define MSHCMDS_SWITCHES \
+    X("advance", -7, ADVCMD) \
+    X("ali", 0, ALICMD) \
+    X("burst", 0, EXPLCMD) \
+    X("comp", 0, COMPCMD) \
+    X("dist", 0, DISTCMD) \
+    X("exit", 0, EXITCMD) \
+    X("folder", 0, FOLDCMD) \
+    X("forw", 0, FORWCMD) \
+    X("help", 0, HELPCMD) \
+    X("inc", 0, INCMD) \
+    X("mark", 0, MARKCMD) \
+    X("mhmail", 0, MAILCMD) \
+    X("mhn", 0, MHNCMD) \
+    X("msgchk", 0, MSGKCMD) \
+    X("next", 0, NEXTCMD) \
+    X("packf", 0, PACKCMD) \
+    X("pick", 0, PICKCMD) \
+    X("prev", 0, PREVCMD) \
+    X("quit", 0, QUITCMD) \
+    X("refile", 0, FILECMD) \
+    X("repl", 0, REPLCMD) \
+    X("rmm", 0, RMMCMD) \
+    X("scan", 0, SCANCMD) \
+    X("send", 0, SENDCMD) \
+    X("show", 0, SHOWCMD) \
+    X("sortm", 0, SORTCMD) \
+    X("whatnow", 0, WHATCMD) \
+    X("whom", 0, WHOMCMD) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MSHCMDS);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MSHCMDS, mshcmds);
+#undef X
 
 
 static void
index 35e7d2737c04caaad2ec8e1b7b9f10f26962eb4c..8212375af6f1433b07d05c94891207eeff26023f 100644 (file)
@@ -93,35 +93,28 @@ forkcmd (char **args, char *pgm)
 }
 
 
-static struct swit distswit[] = {
-#define        DIANSW                    0
-    { "annotate", 0 },
-#define        DINANSW                   1
-    { "noannotate", 0 },
-#define        DIDFSW                    2
-    { "draftfolder +folder", 0 },
-#define        DIDMSW                    3
-    { "draftmessage msg", 0 },
-#define        DINDFSW                   4
-    { "nodraftfolder", 0 },
-#define        DIEDTSW                   5
-    { "editor editor", 0 },
-#define        DINEDSW                   6
-    { "noedit", 0 },
-#define        DIFRMSW                   7
-    { "form formfile", 0 },
-#define        DIINSW                    8
-    { "inplace", 0 },
-#define        DININSW                   9
-    { "noinplace", 0 },
-#define        DIWHTSW                  10
-    { "whatnowproc program", 0 },
-#define        DINWTSW                  11
-    { "nowhatnowproc", 0 },
-#define        DIHELP                   12
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define DIST_SWITCHES \
+    X("annotate", 0, DIANSW) \
+    X("noannotate", 0, DINANSW) \
+    X("draftfolder +folder", 0, DIDFSW) \
+    X("draftmessage msg", 0, DIDMSW) \
+    X("nodraftfolder", 0, DINDFSW) \
+    X("editor editor", 0, DIEDTSW) \
+    X("noedit", 0, DINEDSW) \
+    X("form formfile", 0, DIFRMSW) \
+    X("inplace", 0, DIINSW) \
+    X("noinplace", 0, DININSW) \
+    X("whatnowproc program", 0, DIWHTSW) \
+    X("nowhatnowproc", 0, DINWTSW) \
+    X("help", 0, DIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DIST, distswit);
+#undef X
 
 
 void
@@ -206,23 +199,22 @@ distcmd (char **args)
 }
 
 
-static struct swit explswit[] = {
-#define        EXINSW         0
-    { "inplace", 0 },
-#define        EXNINSW        1
-    { "noinplace", 0 },
-#define        EXQISW         2
-    { "quiet", 0 },
-#define        EXNQISW        3
-    { "noquiet", 0 },
-#define        EXVBSW         4
-    { "verbose", 0 },
-#define        EXNVBSW        5
-    { "noverbose", 0 },
-#define        EXHELP         6
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define EXPLODE_SWITCHES \
+    X("inplace", 0, EXINSW) \
+    X("noinplace", 0, EXNINSW) \
+    X("quiet", 0, EXQISW) \
+    X("noquiet", 0, EXNQISW) \
+    X("verbose", 0, EXVBSW) \
+    X("noverbose", 0, EXNVBSW) \
+    X("help", 0, EXHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(EXPLODE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(EXPLODE, explswit);
+#undef X
 
 
 void
@@ -429,29 +421,25 @@ burst (struct Msg *smsgs, int msgnum, int inplace, int quietsw, int verbosw)
 }
 
 
-static struct swit fileswit[] = {
-#define        FIDRFT               0
-    { "draft", 0 },
-#define        FILINK               1
-    { "link", 0 },
-#define        FINLINK              2
-    { "nolink", 0 },
-#define        FIPRES               3
-    { "preserve", 0 },
-#define FINPRES              4
-    { "nopreserve", 0 },
-#define        FISRC                5
-    { "src +folder", 0 },
-#define        FIFILE               6
-    { "file file", 0 },
-#define        FIPROC               7
-    { "rmmproc program", 0 },
-#define        FINPRC               8
-    { "normmproc", 0 },
-#define        FIHELP               9
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FILE_SWITCHES \
+    X("draft", 0, FIDRFT) \
+    X("link", 0, FILINK) \
+    X("nolink", 0, FINLINK) \
+    X("preserve", 0, FIPRES) \
+    X("nopreserve", 0, FINPRES) \
+    X("src +folder", 0, FISRC) \
+    X("file file", 0, FIFILE) \
+    X("rmmproc program", 0, FIPROC) \
+    X("normmproc", 0, FINPRC) \
+    X("help", 0, FIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FILE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FILE, fileswit);
+#undef X
 
 
 void
@@ -581,41 +569,31 @@ filehak (char **args)
 }
 
 
-static struct swit foldswit[] = {
-#define        FLALSW         0
-    { "all", 0 },
-#define        FLFASW         1
-    { "fast", 0 },
-#define        FLNFASW        2
-    { "nofast", 0 },
-#define        FLHDSW         3
-    { "header", 0 },
-#define        FLNHDSW        4
-    { "noheader", 0 },
-#define        FLPKSW         5
-    { "pack", 0 },
-#define        FLNPKSW        6
-    { "nopack", 0 },
-#define        FLRCSW         7
-    { "recurse", 0 },
-#define        FLNRCSW        8
-    { "norecurse", 0 },
-#define        FLTLSW         9
-    { "total", 0 },
-#define        FLNTLSW       10
-    { "nototal", 0 },
-#define        FLPRSW        11
-    { "print", 0 },
-#define        FLPUSW        12
-    { "push", 0 },
-#define        FLPOSW        13
-    { "pop", 0 },
-#define        FLLISW        14
-    { "list", 0 },
-#define        FLHELP        15
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FOLDER_SWITCHES \
+    X("all", 0, FLALSW) \
+    X("fast", 0, FLFASW) \
+    X("nofast", 0, FLNFASW) \
+    X("header", 0, FLHDSW) \
+    X("noheader", 0, FLNHDSW) \
+    X("pack", 0, FLPKSW) \
+    X("nopack", 0, FLNPKSW) \
+    X("recurse", 0, FLRCSW) \
+    X("norecurse", 0, FLNRCSW) \
+    X("total", 0, FLTLSW) \
+    X("nototal", 0, FLNTLSW) \
+    X("print", 0, FLPRSW) \
+    X("push", 0, FLPUSW) \
+    X("pop", 0, FLPOSW) \
+    X("list", 0, FLLISW) \
+    X("help", 0, FLHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FOLDER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FOLDER, foldswit);
+#undef X
 
 
 void
@@ -796,45 +774,33 @@ fast: ;
 }
 
 
-static struct swit forwswit[] = {
-#define        FOANSW                   0
-    { "annotate", 0 },
-#define        FONANSW                  1
-    { "noannotate", 0 },
-#define        FODFSW                   2
-    { "draftfolder +folder", 0 },
-#define        FODMSW                   3
-    { "draftmessage msg", 0 },
-#define        FONDFSW                  4
-    { "nodraftfolder", 0 },
-#define        FOEDTSW                  5
-    { "editor editor", 0 },
-#define        FONEDSW                  6
-    { "noedit", 0 },
-#define        FOFTRSW                  7
-    { "filter filterfile", 0 },
-#define        FOFRMSW                  8
-    { "form formfile", 0 },
-#define        FOFTSW                   9
-    { "format", 5 },
-#define        FONFTSW                 10
-    { "noformat", 7 },
-#define        FOINSW                  11
-    { "inplace", 0 },
-#define        FONINSW                 12
-    { "noinplace", 0 },
-#define        FOMISW                  13
-    { "mime", 0 },
-#define        FONMISW                 14
-    { "nomime", 0 },
-#define        FOWHTSW                 15
-    { "whatnowproc program", 0 },
-#define        FONWTSW                 16
-    { "nowhatnow", 0 },
-#define        FOHELP                  17
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define FORW_SWITCHES \
+    X("annotate", 0, FOANSW) \
+    X("noannotate", 0, FONANSW) \
+    X("draftfolder +folder", 0, FODFSW) \
+    X("draftmessage msg", 0, FODMSW) \
+    X("nodraftfolder", 0, FONDFSW) \
+    X("editor editor", 0, FOEDTSW) \
+    X("noedit", 0, FONEDSW) \
+    X("filter filterfile", 0, FOFTRSW) \
+    X("form formfile", 0, FOFRMSW) \
+    X("format", 5, FOFTSW) \
+    X("noformat", 7, FONFTSW) \
+    X("inplace", 0, FOINSW) \
+    X("noinplace", 0, FONINSW) \
+    X("mime", 0, FOMISW) \
+    X("nomime", 0, FONMISW) \
+    X("whatnowproc program", 0, FOWHTSW) \
+    X("nowhatnow", 0, FONWTSW) \
+    X("help", 0, FOHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(FORW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(FORW, forwswit);
+#undef X
 
 
 void
@@ -1085,29 +1051,25 @@ helpcmd (char **args)
 }
 
 
-static struct swit markswit[] = {
-#define        MADDSW             0
-    { "add", 0 },
-#define        MDELSW             1
-    { "delete", 0 },
-#define        MLSTSW             2
-    { "list", 0 },
-#define        MSEQSW             3
-    { "sequence name", 0 },
-#define        MPUBSW             4
-    { "public", 0 },
-#define        MNPUBSW            5
-    { "nopublic", 0 },
-#define        MZERSW             6
-    { "zero", 0 },
-#define        MNZERSW            7
-    { "nozero", 0 },
-#define        MHELP              8
-    { "help", 0 },
-#define        MDBUGSW            9
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define MARK_SWITCHES \
+    X("add", 0, MADDSW) \
+    X("delete", 0, MDELSW) \
+    X("list", 0, MLSTSW) \
+    X("sequence name", 0, MSEQSW) \
+    X("public", 0, MPUBSW) \
+    X("nopublic", 0, MNPUBSW) \
+    X("zero", 0, MZERSW) \
+    X("nozero", 0, MNZERSW) \
+    X("help", 0, MHELP) \
+    X("debug", -5, MDBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MARK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MARK, markswit);
+#undef X
 
 
 void
@@ -1273,63 +1235,42 @@ markcmd (char **args)
 }
 
 
-static struct swit mhnswit[] = {
-#define        MHNAUTOSW           0
-    { "auto", 0 },
-#define        MHNNAUTOSW          1
-    { "noauto", 0 },
-#define        MHNDEBUGSW          2
-    { "debug", -5 },
-#define        MHNFORMSW           3
-    { "form formfile", 4 },
-#define        MHNHEADSW           4
-    { "headers", 0 },
-#define        MHNNHEADSW          5
-    { "noheaders", 0 },
-#define        MHNLISTSW           6
-    { "list", 0 },
-#define        MHNNLISTSW          7
-    { "nolist", 0 },
-#define        MHNPARTSW           8
-    { "part number", 0 },
-#define        MHNSIZESW           9
-    { "realsize", 0 },
-#define        MHNNSIZESW         10
-    { "norealsize", 0 },
-#define        MHNRFC934SW        11
-    { "rfc934mode", 0 },
-#define        MHNNRFC934SW       12
-    { "norfc934mode", 0 },
-#define        MHNSERIALSW        13
-    { "serialonly", 0 },
-#define        MHNNSERIALSW       14
-    { "noserialonly", 0 },
-#define        MHNSHOWSW          15
-    { "show", 0 },
-#define        MHNNSHOWSW         16
-    { "noshow", 0 },
-#define        MHNSTORESW         17
-    { "store", 0 },
-#define        MHNNSTORESW        18
-    { "nostore", 0 },
-#define        MHNTYPESW          19
-    { "type content", 0 },
-#define        MHNVERBSW          20
-    { "verbose", 0 },
-#define        MHNNVERBSW         21
-    { "noverbose", 0 },
-#define        MHNHELPSW          22
-    { "help", 0 },
-#define        MHNPROGSW          23
-    { "moreproc program", -4 },
-#define        MHNNPROGSW         24
-    { "nomoreproc", -3 },
-#define        MHNLENSW           25
-    { "length lines", -4 },
-#define        MHNWIDSW           26
-    { "width columns", -4 },
-    { NULL, 0 }
-};
+#define MHN_SWITCHES \
+    X("auto", 0, MHNAUTOSW) \
+    X("noauto", 0, MHNNAUTOSW) \
+    X("debug", -5, MHNDEBUGSW) \
+    X("form formfile", 4, MHNFORMSW) \
+    X("headers", 0, MHNHEADSW) \
+    X("noheaders", 0, MHNNHEADSW) \
+    X("list", 0, MHNLISTSW) \
+    X("nolist", 0, MHNNLISTSW) \
+    X("part number", 0, MHNPARTSW) \
+    X("realsize", 0, MHNSIZESW) \
+    X("norealsize", 0, MHNNSIZESW) \
+    X("rfc934mode", 0, MHNRFC934SW) \
+    X("norfc934mode", 0, MHNNRFC934SW) \
+    X("serialonly", 0, MHNSERIALSW) \
+    X("noserialonly", 0, MHNNSERIALSW) \
+    X("show", 0, MHNSHOWSW) \
+    X("noshow", 0, MHNNSHOWSW) \
+    X("store", 0, MHNSTORESW) \
+    X("nostore", 0, MHNNSTORESW) \
+    X("type content", 0, MHNTYPESW) \
+    X("verbose", 0, MHNVERBSW) \
+    X("noverbose", 0, MHNNVERBSW) \
+    X("help", 0, MHNHELPSW) \
+    X("moreproc program", -4, MHNPROGSW) \
+    X("nomoreproc", -3, MHNNPROGSW) \
+    X("length lines", -4, MHNLENSW) \
+    X("width columns", -4, MHNWIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(MHN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(MHN, mhnswit);
+#undef X
 
 
 void
@@ -1428,13 +1369,17 @@ mhncmd (char **args)
 }
 
 
-static struct swit packswit[] = {
-#define        PAFISW         0
-    { "file name", 0 },
-#define        PAHELP         1
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define PACK_SWITCHES \
+    X("file name", 0, PAFISW) \
+    X("help", 0, PAHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PACK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PACK, packswit);
+#undef X
 
 static int mbx_style = MMDF_FORMAT;
 
@@ -1564,55 +1509,38 @@ packhak (char **args)
 }
 
 
-static struct swit pickswit[] = {
-#define        PIANSW                0
-    { "and", 0 },
-#define        PIORSW                1
-    { "or", 0 },
-#define        PINTSW                2
-    { "not", 0 },
-#define        PILBSW                3
-    { "lbrace", 0 },
-#define        PIRBSW                4
-    { "rbrace", 0 },
-#define        PICCSW                5
-    { "cc  pattern", 0 },
-#define        PIDASW                6
-    { "date  pattern", 0 },
-#define        PIFRSW                7
-    { "from  pattern", 0 },
-#define        PISESW                8
-    { "search  pattern", 0 },
-#define        PISUSW                9
-    { "subject  pattern", 0 },
-#define        PITOSW               10
-    { "to  pattern", 0 },
-#define        PIOTSW               11
-    { "-othercomponent  pattern", 15 },
-#define        PIAFSW               12
-    { "after date", 0 },
-#define        PIBFSW               13
-    { "before date", 0 },
-#define        PIDFSW               14
-    { "datefield field", 5 },
-#define        PISQSW               15
-    { "sequence name", 0 },
-#define        PIPUSW               16
-    { "public", 0 },
-#define        PINPUSW              17
-    { "nopublic", 0 },
-#define        PIZRSW               18
-    { "zero", 0 },
-#define        PINZRSW              19
-    { "nozero", 0 },
-#define        PILISW               20
-    { "list", 0 },
-#define        PINLISW              21
-    { "nolist", 0 },
-#define        PIHELP               22
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define PICK_SWITCHES \
+    X("and", 0, PIANSW) \
+    X("or", 0, PIORSW) \
+    X("not", 0, PINTSW) \
+    X("lbrace", 0, PILBSW) \
+    X("rbrace", 0, PIRBSW) \
+    X("cc  pattern", 0, PICCSW) \
+    X("date  pattern", 0, PIDASW) \
+    X("from  pattern", 0, PIFRSW) \
+    X("search  pattern", 0, PISESW) \
+    X("subject  pattern", 0, PISUSW) \
+    X("to  pattern", 0, PITOSW) \
+    X("-othercomponent  pattern", 15, PIOTSW) \
+    X("after date", 0, PIAFSW) \
+    X("before date", 0, PIBFSW) \
+    X("datefield field", 5, PIDFSW) \
+    X("sequence name", 0, PISQSW) \
+    X("public", 0, PIPUSW) \
+    X("nopublic", 0, PINPUSW) \
+    X("zero", 0, PIZRSW) \
+    X("nozero", 0, PINZRSW) \
+    X("list", 0, PILISW) \
+    X("nolist", 0, PINLISW) \
+    X("help", 0, PIHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PICK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PICK, pickswit);
+#undef X
 
 
 void
@@ -1758,49 +1686,35 @@ pattern: ;
 }
 
 
-static struct swit replswit[] = {
-#define        REANSW                  0
-    { "annotate", 0 },
-#define        RENANSW                 1
-    { "noannotate", 0 },
-#define        RECCSW                  2
-    { "cc type", 0 },
-#define        RENCCSW                 3
-    { "nocc type", 0 },
-#define        REDFSW                  4
-    { "draftfolder +folder", 0 },
-#define        REDMSW                  5
-    { "draftmessage msg", 0 },
-#define        RENDFSW                 6
-    { "nodraftfolder", 0 },
-#define        REEDTSW                 7
-    { "editor editor", 0 },
-#define        RENEDSW                 8
-    { "noedit", 0 },
-#define        REFCCSW                 9
-    { "fcc +folder", 0 },
-#define        REFLTSW                10
-    { "filter filterfile", 0 },
-#define        REFRMSW                11
-    { "form formfile", 0 },
-#define        REINSW                 12
-    { "inplace", 0 },
-#define        RENINSW                13
-    { "noinplace", 0 },
-#define        REQUSW                 14
-    { "query", 0 },
-#define        RENQUSW                15
-    { "noquery", 0 },
-#define        REWHTSW                16
-    { "whatnowproc program", 0 },
-#define        RENWTSW                17
-    { "nowhatnow", 0 },
-#define        REWIDSW                19
-    { "width columns", 0 },
-#define        REHELP                 20
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define REPL_SWITCHES \
+    X("annotate", 0, REANSW) \
+    X("noannotate", 0, RENANSW) \
+    X("cc type", 0, RECCSW) \
+    X("nocc type", 0, RENCCSW) \
+    X("draftfolder +folder", 0, REDFSW) \
+    X("draftmessage msg", 0, REDMSW) \
+    X("nodraftfolder", 0, RENDFSW) \
+    X("editor editor", 0, REEDTSW) \
+    X("noedit", 0, RENEDSW) \
+    X("fcc +folder", 0, REFCCSW) \
+    X("filter filterfile", 0, REFLTSW) \
+    X("form formfile", 0, REFRMSW) \
+    X("inplace", 0, REINSW) \
+    X("noinplace", 0, RENINSW) \
+    X("query", 0, REQUSW) \
+    X("noquery", 0, RENQUSW) \
+    X("whatnowproc program", 0, REWHTSW) \
+    X("nowhatnow", 0, RENWTSW) \
+    X("width columns", 0, REWIDSW) \
+    X("help", 0, REHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REPL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REPL, replswit);
+#undef X
 
 
 void
@@ -1892,11 +1806,16 @@ replcmd (char **args)
 }
 
 
-static struct swit rmmswit[] = {
-#define        RMHELP    0
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RMM_SWITCHES \
+    X("help", 0, RMHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMM, rmmswit);
+#undef X
 
 
 void
@@ -2001,25 +1920,23 @@ rmm (void)
 }
 
 
-static struct swit scanswit[] = {
-#define        SCCLR              0
-    { "clear", 0 },
-#define        SCNCLR             1
-    { "noclear", 0 },
-#define        SCFORM             2
-    { "form formatfile", 0 },
-#define        SCFMT              3
-    { "format string", 5 },
-#define        SCHEAD             4
-    { "header", 0 },
-#define SCNHEAD            5
-    { "noheader", 0 },
-#define        SCWID              6
-    { "width columns", 0 },
-#define        SCHELP             7
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SCAN_SWITCHES \
+    X("clear", 0, SCCLR) \
+    X("noclear", 0, SCNCLR) \
+    X("form formatfile", 0, SCFORM) \
+    X("format string", 5, SCFMT) \
+    X("header", 0, SCHEAD) \
+    X("noheader", 0, SCNHEAD) \
+    X("width columns", 0, SCWID) \
+    X("help", 0, SCHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SCAN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SCAN, scanswit);
+#undef X
 
 
 void
@@ -2156,31 +2073,26 @@ scancmd (char **args)
 }
 
 
-static struct swit showswit[] = {
-#define        SHDRAFT               0
-    { "draft", 5 },
-#define        SHFORM                1
-    { "form formfile", 4 },
-#define        SHPROG                2
-    { "moreproc program", 4 },
-#define        SHNPROG               3
-    { "nomoreproc", 3 },
-#define        SHLEN                 4
-    { "length lines", 4 },
-#define        SHWID                 5
-    { "width columns", 4 },
-#define        SHSHOW                6
-    { "showproc program", 4 },
-#define        SHNSHOW               7
-    { "noshowproc", 3 },
-#define        SHHEAD                8
-    { "header", 4 },
-#define SHNHEAD               9
-    { "noheader", 3 },
-#define        SHHELP               10
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SHOW_SWITCHES \
+    X("draft", 5, SHDRAFT) \
+    X("form formfile", 4, SHFORM) \
+    X("moreproc program", 4, SHPROG) \
+    X("nomoreproc", 3, SHNPROG) \
+    X("length lines", 4, SHLEN) \
+    X("width columns", 4, SHWID) \
+    X("showproc program", 4, SHSHOW) \
+    X("noshowproc", 3, SHNSHOW) \
+    X("header", 4, SHHEAD) \
+    X("noheader", 3, SHNHEAD) \
+    X("help", 0, SHHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SHOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SHOW, showswit);
+#undef X
 
 
 void
@@ -2584,25 +2496,23 @@ out:
 }
 
 
-static struct swit sortswit[] = {
-#define        SODATE               0
-    { "datefield field", 0 },
-#define        SOSUBJ               1
-    { "textfield field", 0 },
-#define        SONSUBJ              2
-    { "notextfield", 0 },
-#define        SOLIMT               3
-    { "limit days", 0 },
-#define        SONLIMT              4
-    { "nolimit", 0 },
-#define        SOVERB               5
-    { "verbose", 0 },
-#define        SONVERB              6
-    { "noverbose", 0 },
-#define        SOHELP               7
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SORT_SWITCHES \
+    X("datefield field", 0, SODATE) \
+    X("textfield field", 0, SOSUBJ) \
+    X("notextfield", 0, SONSUBJ) \
+    X("limit days", 0, SOLIMT) \
+    X("nolimit", 0, SONLIMT) \
+    X("verbose", 0, SOVERB) \
+    X("noverbose", 0, SONVERB) \
+    X("help", 0, SOHELP) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SORT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SORT, sortswit);
+#undef X
 
 
 void
index 10854dc98ea5a4ec800248152cd41d6163520479..e88a0dd7e8712d86d4e71518825aafa0b0dddbfa 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
 #include <h/crawl_folders.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define MODESW 0
-    { "mode", 1 },
-#define FOLDERSSW 1
-    { "folders", 1 },
-#define VERSIONSW 2
-    { "version", 1 },
-#define HELPSW 3
-    { "help", 1 },
-    { NULL, 0 }
-};
+#define NEW_SWITCHES \
+    X("mode", 1, MODESW) \
+    X("folders", 1, FOLDERSSW) \
+    X("version", 1, VERSIONSW) \
+    X("help", 1, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(NEW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(NEW, switches);
+#undef X
 
 static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW;
 
index cd003dd78824bfa7ec1dc496625eeec84ed3bf1c..53e696afb78f69233a72311b9e1cf8f6c5ee84b8 100644 (file)
 #include <h/utils.h>
 #include <errno.h>
 
-static struct swit switches[] = {
-#define FILESW         0
-    { "file name", 0 },
-#define MBOXSW         1
-    { "mbox", 0 },
-#define MMDFSW         2
-    { "mmdf", 0 },
-#define VERSIONSW      3
-    { "version", 0 },
-#define        HELPSW         4
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define PACKF_SWITCHES \
+    X("file name", 0, FILESW) \
+    X("mbox", 0, MBOXSW) \
+    X("mmdf", 0, MMDFSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PACKF);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PACKF, switches);
+#undef X
 
 static int md = NOTOK;
 static int mbx_style = MBOX_FORMAT;
index 6f450af20274a2dca1ef4e5bb7c522edf3fe35ec..5549ea64ac24eb88dffc4bf50d515fdc84c9bda1 100644 (file)
 #include <h/picksbr.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        ANDSW                   0
-    { "and", 0 },
-#define        ORSW                    1
-    { "or", 0 },
-#define        NOTSW                   2
-    { "not", 0 },
-#define        LBRSW                   3
-    { "lbrace", 0 },
-#define        RBRSW                   4
-    { "rbrace", 0 },
-#define        CCSW                    5
-    { "cc  pattern", 0 },
-#define        DATESW                  6
-    { "date  pattern", 0 },
-#define        FROMSW                  7
-    { "from  pattern", 0 },
-#define        SRCHSW                  8
-    { "search  pattern", 0 },
-#define        SUBJSW                  9
-    { "subject  pattern", 0 },
-#define        TOSW                   10
-    { "to  pattern", 0 },
-#define        OTHRSW                 11
-    { "-othercomponent  pattern", 0 },
-#define        AFTRSW                 12
-    { "after date", 0 },
-#define        BEFRSW                 13
-    { "before date", 0 },
-#define        DATFDSW                14
-    { "datefield field", 5 },
-#define        SEQSW                  15
-    { "sequence name", 0 },
-#define        NSEQSW                 16
-    { "nosequence", 0 },
-#define        PUBLSW                 17
-    { "public", 0 },
-#define        NPUBLSW                18
-    { "nopublic", 0 },
-#define        ZEROSW                 19
-    { "zero", 0 },
-#define        NZEROSW                20
-    { "nozero", 0 },
-#define        LISTSW                 21
-    { "list", 0 },
-#define        NLISTSW                22
-    { "nolist", 0 },
-#define VERSIONSW              23
-    { "version", 0 },
-#define        HELPSW                 24
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define PICK_SWITCHES \
+    X("and", 0, ANDSW) \
+    X("or", 0, ORSW) \
+    X("not", 0, NOTSW) \
+    X("lbrace", 0, LBRSW) \
+    X("rbrace", 0, RBRSW) \
+    X("cc  pattern", 0, CCSW) \
+    X("date  pattern", 0, DATESW) \
+    X("from  pattern", 0, FROMSW) \
+    X("search  pattern", 0, SRCHSW) \
+    X("subject  pattern", 0, SUBJSW) \
+    X("to  pattern", 0, TOSW) \
+    X("-othercomponent  pattern", 0, OTHRSW) \
+    X("after date", 0, AFTRSW) \
+    X("before date", 0, BEFRSW) \
+    X("datefield field", 5, DATFDSW) \
+    X("sequence name", 0, SEQSW) \
+    X("nosequence", 0, NSEQSW) \
+    X("public", 0, PUBLSW) \
+    X("nopublic", 0, NPUBLSW) \
+    X("zero", 0, ZEROSW) \
+    X("nozero", 0, NZEROSW) \
+    X("list", 0, LISTSW) \
+    X("nolist", 0, NLISTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PICK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PICK, switches);
+#undef X
 
 static int listsw = -1;
 
index 91893e3cbf89f71138e39b0405d785bddf51a94b..7b64f819c0994df2d1da55a1a8b1b3462c8f82bb 100644 (file)
 #endif
 #include <time.h>
 
-static struct swit parswit[] = {
-#define        PRAND                   0
-    { "and", 0 },
-#define        PROR                    1
-    { "or", 0 },
-#define        PRNOT                   2
-    { "not", 0 },
-#define        PRLBR                   3
-    { "lbrace", 0 },
-#define        PRRBR                   4
-    { "rbrace", 0 },
-#define        PRCC                    5
-    { "cc  pattern", 0 },
-#define        PRDATE                  6
-    { "date  pattern", 0 },
-#define        PRFROM                  7
-    { "from  pattern", 0 },
-#define        PRSRCH                  8
-    { "search  pattern", 0 },
-#define        PRSUBJ                  9
-    { "subject  pattern", 0 },
-#define        PRTO                   10
-    { "to  pattern", 0 },
-#define        PROTHR                 11
-    { "-othercomponent  pattern", 15 },
-#define        PRAFTR                 12
-    { "after date", 0 },
-#define        PRBEFR                 13
-    { "before date", 0 },
-#define        PRDATF                 14
-    { "datefield field", 5 },
-    { NULL, 0 }
-};
+#define PARSE_SWITCHES \
+    X("and", 0, PRAND) \
+    X("or", 0, PROR) \
+    X("not", 0, PRNOT) \
+    X("lbrace", 0, PRLBR) \
+    X("rbrace", 0, PRRBR) \
+    X("cc  pattern", 0, PRCC) \
+    X("date  pattern", 0, PRDATE) \
+    X("from  pattern", 0, PRFROM) \
+    X("search  pattern", 0, PRSRCH) \
+    X("subject  pattern", 0, PRSUBJ) \
+    X("to  pattern", 0, PRTO) \
+    X("-othercomponent  pattern", 15, PROTHR) \
+    X("after date", 0, PRAFTR) \
+    X("before date", 0, PRBEFR) \
+    X("datefield field", 5, PRDATF) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PARSE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PARSE, parswit);
+#undef X
 
 /* DEFINITIONS FOR PATTERN MATCHING */
 
index 6b0786192c4be04df52d3dcc1346b03a4097d3af..f6f7924c01fe476f4d09dbed1c9d57a0007fd09b 100644 (file)
    0  : Switch can't be abbreviated;               switch shown in -help.
    #  : Switch can be abbreviated to # characters; switch shown in -help. */
 
-static struct swit switches[] = {
-#define        ALIASW                    0
-    { "alias aliasfile", 0 },
-#define        CHKSW                     1
-    { "check", -5 },                   /* interface from whom */
-#define        NCHKSW                    2
-    { "nocheck", -7 },                 /* interface from whom */
-#define        DEBUGSW                   3
-    { "debug", -5 },
-#define        DISTSW                    4
-    { "dist", -4 },                    /* interface from dist */
-#define        FILTSW                    5
-    { "filter filterfile", 0 },
-#define        NFILTSW                   6
-    { "nofilter", 0 },
-#define        FRMTSW                    7
-    { "format", 0 },
-#define        NFRMTSW                   8
-    { "noformat", 0 },
-#define        LIBSW                     9
-    { "library directory", -7 },       /* interface from send, whom */
-#define        MIMESW                   10
-    { "mime", 0 },
-#define        NMIMESW                  11
-    { "nomime", 0 },
-#define        MSGDSW                   12
-    { "msgid", 0 },
-#define        NMSGDSW                  13
-    { "nomsgid", 0 },
-#define        VERBSW                   14
-    { "verbose", 0 },
-#define        NVERBSW                  15
-    { "noverbose", 0 },
-#define        WATCSW                   16
-    { "watch", 0 },
-#define        NWATCSW                  17
-    { "nowatch", 0 },
-#define        WHOMSW                   18
-    { "whom", -4 },                    /* interface from whom */
-#define        WIDTHSW                  19
-    { "width columns", 0 },
-#define VERSIONSW                20
-    { "version", 0 },
-#define        HELPSW                   21
-    { "help", 0 },
-#define BITSTUFFSW               22
-    { "dashstuffing", -12 },           /* should we dashstuff BCC messages? */
-#define NBITSTUFFSW              23
-    { "nodashstuffing", -14 },
-#define        ANNOSW                   24
-    { "idanno number", -6 },           /* interface from send    */
-#define        CLIESW                   25
-    { "client host", -6 },
-#define        SERVSW                   26
-    { "server host", 6 },              /* specify alternate SMTP server */
-#define        SNOOPSW                  27
-    { "snoop", -5 },                   /* snoop the SMTP transaction */
-#define        PARTSW                   28
-    { "partno", -6 },
-#define        QUEUESW                  29
-    { "queued", -6 },
-#define SASLSW                   30
-    { "sasl", SASLminc(-4) },
-#define NOSASLSW                 31
-    { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW              32
-    { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW               33
-    { "saslmech", SASLminc(-5) },
-#define USERSW                   34
-    { "user", SASLminc(-4) },
-#define PORTSW                  35
-    { "port server port name/number", 4 },
-#define TLSSW                   36
-    { "tls", TLSminc(-3) },
-#define NTLSSW                   37
-    { "notls", TLSminc(-5) },
-#define FILEPROCSW              38
-    { "fileproc", -4 },
-#define MHLPROCSW               39
-    { "mhlproc", -3 },
-#define MTSSW                   40
-    { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW             41
-    { "messageid localname|random", 2 },
-    { NULL, 0 }
-};
+#define POST_SWITCHES \
+    X("alias aliasfile", 0, ALIASW) \
+    X("check", -5, CHKSW) /* interface from whom */ \
+    X("nocheck", -7, NCHKSW) /* interface from whom */ \
+    X("debug", -5, DEBUGSW) \
+    X("dist", -4, DISTSW) /* interface from dist */ \
+    X("filter filterfile", 0, FILTSW) \
+    X("nofilter", 0, NFILTSW) \
+    X("format", 0, FRMTSW) \
+    X("noformat", 0, NFRMTSW) \
+    X("library directory", -7, LIBSW) /* interface from send, whom */ \
+    X("mime", 0, MIMESW) \
+    X("nomime", 0, NMIMESW) \
+    X("msgid", 0, MSGDSW) \
+    X("nomsgid", 0, NMSGDSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("watch", 0, WATCSW) \
+    X("nowatch", 0, NWATCSW) \
+    X("whom", -4, WHOMSW) /* interface from whom */ \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("dashstuffing", -12, BITSTUFFSW) /* should we dashstuff BCC messages? */ \
+    X("nodashstuffing", -14, NBITSTUFFSW) \
+    X("idanno number", -6, ANNOSW) /* interface from send    */ \
+    X("client host", -6, CLIESW) \
+    X("server host", 6, SERVSW) /* specify alternate SMTP server */ \
+    X("snoop", -5, SNOOPSW) /* snoop the SMTP transaction */ \
+    X("partno", -6, PARTSW) \
+    X("queued", -6, QUEUESW) \
+    X("sasl", SASLminc(-4), SASLSW) \
+    X("nosasl", SASLminc(-6), NOSASLSW) \
+    X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+    X("saslmech", SASLminc(-5), SASLMECHSW) \
+    X("user", SASLminc(-4), USERSW) \
+    X("port server port name/number", 4, PORTSW) \
+    X("tls", TLSminc(-3), TLSSW) \
+    X("notls", TLSminc(-5), NTLSSW) \
+    X("fileproc", -4, FILEPROCSW) \
+    X("mhlproc", -3, MHLPROCSW) \
+    X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+    X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(POST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(POST, switches);
+#undef X
 
 
 struct headers {
index 795e4724d4966061c274ef7423606896a15ad555..d950163db31242d5ad937223a352bf86f267f702 100644 (file)
 # define CERASE '#'
 #endif
 
-static struct swit switches[] = {
-#define        ERASESW 0
-    { "erase chr", 0 },
-#define        KILLSW  1
-    { "kill chr", 0 },
-#define        PREPSW  2
-    { "prepend", 0 },
-#define        NPREPSW 3
-    { "noprepend", 0 },        
-#define        RAPDSW  4
-    { "rapid", 0 },
-#define        NRAPDSW 5
-    { "norapid", 0 },
-#define        BODYSW  6
-    { "body", -4 },
-#define        NBODYSW 7
-    { "nobody", -6 },
-#define        DOTSW   8
-    { "doteof", 0 },
-#define        NDOTSW  9
-    { "nodoteof", 0 },
-#define VERSIONSW 10
-    { "version", 0 },
-#define        HELPSW  11
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define PROMPTER_SWITCHES \
+    X("erase chr", 0, ERASESW) \
+    X("kill chr", 0, KILLSW) \
+    X("prepend", 0, PREPSW) \
+    X("noprepend", 0, NPREPSW) \
+    X("rapid", 0, RAPDSW) \
+    X("norapid", 0, NRAPDSW) \
+    X("body", -4, BODYSW) \
+    X("nobody", -6, NBODYSW) \
+    X("doteof", 0, DOTSW) \
+    X("nodoteof", 0, NDOTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PROMPTER);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PROMPTER, switches);
+#undef X
 
 
 static struct termios tio;
index d3f36caa594f7734c105c8a376e3b243c74013cf..8f88639a9d558a1c9f0d9ead58de5fbe31942a9a 100644 (file)
 #include <h/mts.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define        FORMSW       0
-    { "form formfile",  4 },
-#define VERSIONSW    1
-    { "version", 0 },
-#define        HELPSW       2
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RCVDIST_SWITCHES \
+    X("form formfile", 4, FORMSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVDIST);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVDIST, switches);
+#undef X
 
 static char backup[BUFSIZ] = "";
 static char drft[BUFSIZ] = "";
index f9e5bbb62c1e54e022e9ea0c69b8f7673a084784..4725f26cc94a876066bfaf828a863badbc4f461f 100644 (file)
 #include <h/tws.h>
 #include <h/mts.h>
 
-static struct swit switches[] = {
-#define MBOXSW       0
-    { "mbox", 0 },
-#define MMDFSW       1
-    { "mmdf", 0 },
-#define VERSIONSW    2
-    { "version", 0 },
-#define        HELPSW       3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RCVPACK_SWITCHES \
+    X("mbox", 0, MBOXSW) \
+    X("mmdf", 0, MMDFSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVPACK);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVPACK, switches);
+#undef X
 
 /*
  * default format in which to save messages
index acf54beb237bc8e779e00f258bbf711516942463..3afe12e3dcd789f82e0f248d1f8a1a50d78fa90d 100644 (file)
 #include <signal.h>
 #include <h/mts.h>
 
-static struct swit switches[] = {
-#define CRETSW         0
-    { "create",        0 },
-#define NCRETSW        1
-    { "nocreate", 0 },
-#define UNSEENSW       2
-    { "unseen", 0 },
-#define NUNSEENSW      3
-    { "nounseen", 0 },
-#define PUBSW          4
-    { "public",        0 },
-#define NPUBSW         5
-    { "nopublic",  0 },
-#define ZEROSW         6
-    { "zero",  0 },
-#define NZEROSW        7
-    { "nozero",        0 },
-#define SEQSW          8
-    { "sequence name", 0 },
-#define VERSIONSW      9
-    { "version", 0 },
-#define HELPSW        10
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RCVSTORE_SWITCHES \
+    X("create", 0, CRETSW) \
+    X("nocreate", 0, NCRETSW) \
+    X("unseen", 0, UNSEENSW) \
+    X("nounseen", 0, NUNSEENSW) \
+    X("public", 0, PUBSW) \
+    X("nopublic", 0, NPUBSW) \
+    X("zero", 0, ZEROSW) \
+    X("nozero", 0, NZEROSW) \
+    X("sequence name", 0, SEQSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVSTORE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVSTORE, switches);
+#undef X
 
 
 /*
index 29f2dd9d639845cbdfaef1d1ece030ede7e43299..9cd77dd6e37bb37241efd38a8455d1f02fb660be 100644 (file)
 %<(mymbox{from})%<{to}To:%14(friendly{to})%>%>%<(zero)%17(friendly{from})%>  \
 %{subject}%<{body}<<%{body}>>%>"
 
-static struct swit switches[] = {
-#define        BIFFSW  0
-    { "biff", 0 },
-#define        FORMSW  1
-    { "form formatfile", 0 },
-#define        FMTSW   2
-    { "format string", 5 },
-#define WIDTHSW 3
-    { "width columns", 0 },
-#define NLSW    4
-    { "newline", 0 },
-#define NNLSW   5
-    { "nonewline", 0 },
-#define BELSW  6
-    { "bell", 0 },
-#define        NBELSW  7
-    { "nobell", 0 },
-#define VERSIONSW 8
-    { "version", 0 },
-#define        HELPSW  9
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RCVTTY_SWITCHES \
+    X("biff", 0, BIFFSW) \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("newline", 0, NLSW) \
+    X("nonewline", 0, NNLSW) \
+    X("bell", 0, BELSW) \
+    X("nobell", 0, NBELSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RCVTTY);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RCVTTY, switches);
+#undef X
 
 static jmp_buf myctx;
 static int bell = 1;
index 2bd12ed837f80cad03850eacf948d7fc30f2b679..ae71de23e12eb1ffc48527289ffe239b4c76c190 100644 (file)
 #include <fcntl.h>
 #include <errno.h>
 
-static struct swit switches[] = {
-#define        DRAFTSW          0
-    { "draft", 0 },
-#define        LINKSW           1
-    { "link", 0 },
-#define        NLINKSW          2
-    { "nolink", 0 },
-#define        PRESSW           3
-    { "preserve", 0 },
-#define        NPRESSW          4
-    { "nopreserve", 0 },
-#define UNLINKSW         5
-    { "unlink", 0 },
-#define NUNLINKSW        6
-    { "nounlink", 0 },
-#define        SRCSW            7
-    { "src +folder", 0 },
-#define        FILESW           8
-    { "file file", 0 },
-#define        RPROCSW          9
-    { "rmmproc program", 0 },
-#define        NRPRCSW         10
-    { "normmproc", 0 },
-#define VERSIONSW       11
-    { "version", 0 },
-#define        HELPSW          12
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define REFILE_SWITCHES \
+    X("draft", 0, DRAFTSW) \
+    X("link", 0, LINKSW) \
+    X("nolink", 0, NLINKSW) \
+    X("preserve", 0, PRESSW) \
+    X("nopreserve", 0, NPRESSW) \
+    X("unlink", 0, UNLINKSW) \
+    X("nounlink", 0, NUNLINKSW) \
+    X("src +folder", 0, SRCSW) \
+    X("file file", 0, FILESW) \
+    X("rmmproc program", 0, RPROCSW) \
+    X("normmproc", 0, NRPRCSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REFILE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REFILE, switches);
+#undef X
 
 static char maildir[BUFSIZ];
 
index cc8a86b9bda2e7e1ba9d27e413c12e47102bab2c..b089dbac1e7585fae6513a4c074e54a4f247e85e 100644 (file)
 #include <h/utils.h>
 
 
-static struct swit switches[] = {
-#define GROUPSW                0
-    { "group", 0 },
-#define NGROUPSW               1
-    { "nogroup", 0 },
-#define        ANNOSW                 2
-    { "annotate", 0 },
-#define        NANNOSW                3
-    { "noannotate", 0 },
-#define        CCSW                   4
-    { "cc all|to|cc|me", 0 },
-#define        NCCSW                  5
-    { "nocc type", 0 },
-#define        DFOLDSW                6
-    { "draftfolder +folder", 0 },
-#define        DMSGSW                 7
-    { "draftmessage msg", 0 },
-#define        NDFLDSW                8
-    { "nodraftfolder", 0 },
-#define        EDITRSW                9
-    { "editor editor", 0 },
-#define        NEDITSW               10
-    { "noedit", 0 },
-#define        FCCSW                 11
-    { "fcc folder", 0 },
-#define        FILTSW                12
-    { "filter filterfile", 0 },
-#define        FORMSW                13
-    { "form formfile", 0 },
-#define        FRMTSW                14
-    { "format", 5 },
-#define        NFRMTSW               15
-    { "noformat", 7 },
-#define        INPLSW                16
-    { "inplace", 0 },
-#define        NINPLSW               17
-    { "noinplace", 0 },
-#define MIMESW                18
-    { "mime", 0 },
-#define NMIMESW               19
-    { "nomime", 0 },
-#define        QURYSW                20
-    { "query", 0 },
-#define        NQURYSW               21
-    { "noquery", 0 },
-#define        WHATSW                22
-    { "whatnowproc program", 0 },
-#define        NWHATSW               23
-    { "nowhatnowproc", 0 },
-#define        WIDTHSW               24
-    { "width columns", 0 },
-#define VERSIONSW             25
-    { "version", 0 },
-#define        HELPSW                26
-    { "help", 0 },
-#define        FILESW                27
-    { "file file", 4 },                        /* interface from msh */
-#define        BILDSW                28
-    { "build", 5 },                    /* interface from mhe */
-#define ATFILESW              29
-    { "atfile", 0 },
-#define NOATFILESW            30
-    { "noatfile", 0 },
-#define FMTPROCSW             31
-    { "fmtproc program", 0 },
-#define NFMTPROCSW            32
-    { "nofmtproc", 0 },
-
-    { NULL, 0 }
-};
-
-static struct swit ccswitches[] = {
-#define        CTOSW   0
-    { "to", 0 },
-#define        CCCSW   1
-    { "cc", 0 },
-#define        CMESW   2
-    { "me", 0 },
-#define        CALSW   3
-    { "all", 0 },
-    { NULL, 0 }
-};
-
-static struct swit aqrnl[] = {
-#define        NOSW         0
-    { "quit", 0 },
-#define        YESW         1
-    { "replace", 0 },
-#define        LISTDSW      2
-    { "list", 0 },
-#define        REFILSW      3
-    { "refile +folder", 0 },
-#define NEWSW        4
-    { "new", 0 },
-    { NULL, 0 }
-};
+#define REPL_SWITCHES \
+    X("group", 0, GROUPSW) \
+    X("nogroup", 0, NGROUPSW) \
+    X("annotate", 0, ANNOSW) \
+    X("noannotate", 0, NANNOSW) \
+    X("cc all|to|cc|me", 0, CCSW) \
+    X("nocc type", 0, NCCSW) \
+    X("draftfolder +folder", 0, DFOLDSW) \
+    X("draftmessage msg", 0, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("editor editor", 0, EDITRSW) \
+    X("noedit", 0, NEDITSW) \
+    X("fcc folder", 0, FCCSW) \
+    X("filter filterfile", 0, FILTSW) \
+    X("form formfile", 0, FORMSW) \
+    X("format", 5, FRMTSW) \
+    X("noformat", 7, NFRMTSW) \
+    X("inplace", 0, INPLSW) \
+    X("noinplace", 0, NINPLSW) \
+    X("mime", 0, MIMESW) \
+    X("nomime", 0, NMIMESW) \
+    X("query", 0, QURYSW) \
+    X("noquery", 0, NQURYSW) \
+    X("whatnowproc program", 0, WHATSW) \
+    X("nowhatnowproc", 0, NWHATSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("file file", 4, FILESW) /* interface from msh */ \
+    X("build", 5, BILDSW) /* interface from mhe */ \
+    X("atfile", 0, ATFILESW) \
+    X("noatfile", 0, NOATFILESW) \
+    X("fmtproc program", 0, FMTPROCSW) \
+    X("nofmtproc", 0, NFMTPROCSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(REPL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(REPL, switches);
+#undef X
+
+#define CC_SWITCHES \
+    X("to", 0, CTOSW) \
+    X("cc", 0, CCCSW) \
+    X("me", 0, CMESW) \
+    X("all", 0, CALSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(CC);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(CC, ccswitches);
+#undef X
+
+#define DISPO_SWITCHES \
+    X("quit", 0, NOSW) \
+    X("replace", 0, YESW) \
+    X("list", 0, LISTDSW) \
+    X("refile +folder", 0, REFILSW) \
+    X("new", 0, NEWSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(DISPO);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(DISPO, aqrnl);
+#undef X
 
 static struct swit aqrl[] = {
-    { "quit", 0 },
-    { "replace", 0 },
-    { "list", 0 },
-    { "refile +folder", 0 },
+    { "quit", 0, NOSW },
+    { "replace", 0, YESW },
+    { "list", 0, LISTDSW },
+    { "refile +folder", 0, REFILSW },
     { NULL, 0 }
 };
 
index c9a04f55eb636121047d872de3e019079acc0608..9e922475c6df63ed8cec4fdb3a1ebb3f661bdc78 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -9,17 +9,19 @@
 
 #include <h/mh.h>
 
-static struct swit switches[] = {
-#define        INTRSW            0
-    { "interactive", 0 },
-#define        NINTRSW           1
-    { "nointeractive", 0 },
-#define VERSIONSW         2
-    { "version", 0 },
-#define        HELPSW            3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RMF_SWITCHES \
+    X("interactive", 0, INTRSW) \
+    X("nointeractive", 0, NINTRSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMF);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMF, switches);
+#undef X
 
 /*
  * static prototypes
index 28c26fb4703a047e78f1e89506bdf28028bf5f29..d96622ed835c3492546098874d38a303c462bd26 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
 #include <h/mh.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define UNLINKSW      0
-    { "unlink", 0 },
-#define NUNLINKSW    1
-    { "nounlink", 0 },
-#define VERSIONSW     2
-    { "version", 0 },
-#define        HELPSW        3
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define RMM_SWITCHES \
+    X("unlink", 0, UNLINKSW) \
+    X("nounlink", 0, NUNLINKSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(RMM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(RMM, switches);
+#undef X
 
 
 int
index b4980d7c6ed5be1aa7f792acdb675b6a2e6ea435..e1b9a16576f32d64bea5b4a2b7ac7ffcb699031a 100644 (file)
 #include <h/utils.h>
 #include <errno.h>
 
-static struct swit switches[] = {
-#define        CLRSW   0
-    { "clear", 0 },
-#define        NCLRSW  1
-    { "noclear", 0 },
-#define        FORMSW  2
-    { "form formatfile", 0 },
-#define        FMTSW   3
-    { "format string", 5 },
-#define        HEADSW  4
-    { "header", 0 },
-#define        NHEADSW 5
-    { "noheader", 0 },
-#define        WIDTHSW 6
-    { "width columns", 0 },
-#define        REVSW   7
-    { "reverse", 0 },
-#define        NREVSW  8
-    { "noreverse", 0 },
-#define        FILESW  9
-    { "file file", 4 },
-#define VERSIONSW 10
-    { "version", 0 },
-#define        HELPSW  11
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SCAN_SWITCHES \
+    X("clear", 0, CLRSW) \
+    X("noclear", 0, NCLRSW) \
+    X("form formatfile", 0, FORMSW) \
+    X("format string", 5, FMTSW) \
+    X("header", 0, HEADSW) \
+    X("noheader", 0, NHEADSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("reverse", 0, REVSW) \
+    X("noreverse", 0, NREVSW) \
+    X("file file", 4, FILESW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SCAN);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SCAN, switches);
+#undef X
 
 
 /*
index 7f0529e7ea95411fb7894f676553ebf11bbf87f4..1bfd0608cf0ea920d4260789f6f4f25697b64502 100644 (file)
 # define TLSminc(a)   0
 #endif /* TLS_SUPPORT */
 
-static struct swit switches[] = {
-#define        ALIASW                 0
-    { "alias aliasfile", 0 },
-#define        DEBUGSW                1
-    { "debug", -5 },
-#define        DRAFTSW                2
-    { "draft", 0 },
-#define        DFOLDSW                3
-    { "draftfolder +folder", 6 },
-#define        DMSGSW                 4
-    { "draftmessage msg", 6 },
-#define        NDFLDSW                5
-    { "nodraftfolder", 0 },
-#define        FILTSW                 6
-    { "filter filterfile", 0 },
-#define        NFILTSW                7
-    { "nofilter", 0 },
-#define        FRMTSW                 8
-    { "format", 0 },
-#define        NFRMTSW                9
-    { "noformat", 0 },
-#define        FORWSW                10
-    { "forward", 0 },
-#define        NFORWSW               11
-    { "noforward", 0 },
-#define MIMESW                12
-    { "mime", 0 },
-#define NMIMESW               13
-    { "nomime", 0 },
-#define        MSGDSW                14
-    { "msgid", 0 },
-#define        NMSGDSW               15
-    { "nomsgid", 0 },
-#define        PUSHSW                16
-    { "push", 0 },
-#define        NPUSHSW               17
-    { "nopush", 0 },
-#define        SPLITSW               18
-    { "split seconds", 0 },
-#define        UNIQSW                19
-    { "unique", -6 },
-#define        NUNIQSW               20
-    { "nounique", -8 },
-#define        VERBSW                21
-    { "verbose", 0 },
-#define        NVERBSW               22
-    { "noverbose", 0 },
-#define        WATCSW                23
-    { "watch", 0 },
-#define        NWATCSW               24
-    { "nowatch", 0 },
-#define        WIDTHSW               25
-    { "width columns", 0 },
-#define VERSIONSW             26
-    { "version", 0 },
-#define        HELPSW                27
-    { "help", 0 },
-#define BITSTUFFSW            28
-    { "dashstuffing", -12 },
-#define NBITSTUFFSW           29
-    { "nodashstuffing", -14 },
-#define        MAILSW                30
-    { "mail", -4 },
-#define        SAMLSW                31
-    { "saml", -4 },
-#define        SENDSW                32
-    { "send", -4 },
-#define        SOMLSW                33
-    { "soml", -4 },
-#define        CLIESW                34
-    { "client host", -6 },
-#define        SERVSW                35
-    { "server host", 6 },
-#define        SNOOPSW               36
-    { "snoop", 5 },
-#define SASLSW                37
-    { "sasl", SASLminc(4) },
-#define NOSASLSW              38
-    { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW           39
-    { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW            40
-    { "saslmech mechanism", SASLminc(-5) },
-#define USERSW                41
-    { "user username", SASLminc(-4) },
-#define ATTACHSW              42
-    { "attach", 6 },
-#define NOATTACHSW            43
-    { "noattach", 0 },
-#define ATTACHFORMATSW        44
-    { "attachformat", 7 },
-#define PORTSW               45
-    { "port server-port-name/number" , 4 },
-#define TLSSW                46
-    { "tls", TLSminc(-3) },
-#define NTLSSW                47
-    { "notls", TLSminc(-5) },
-#define MTSSW                48
-    { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW          49
-    { "messageid localname|random", 2 },
-    { NULL, 0 }
-};
-
-static struct swit anyl[] = {
-#define        NOSW     0
-    { "no", 0 },
-#define        YESW     1
-    { "yes", 0 },
-#define        LISTDSW  2
-    { "list", 0 },
-    { NULL, 0 }
-};
+#define SEND_SWITCHES \
+    X("alias aliasfile", 0, ALIASW) \
+    X("debug", -5, DEBUGSW) \
+    X("draft", 0, DRAFTSW) \
+    X("draftfolder +folder", 6, DFOLDSW) \
+    X("draftmessage msg", 6, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("filter filterfile", 0, FILTSW) \
+    X("nofilter", 0, NFILTSW) \
+    X("format", 0, FRMTSW) \
+    X("noformat", 0, NFRMTSW) \
+    X("forward", 0, FORWSW) \
+    X("noforward", 0, NFORWSW) \
+    X("mime", 0, MIMESW) \
+    X("nomime", 0, NMIMESW) \
+    X("msgid", 0, MSGDSW) \
+    X("nomsgid", 0, NMSGDSW) \
+    X("push", 0, PUSHSW) \
+    X("nopush", 0, NPUSHSW) \
+    X("split seconds", 0, SPLITSW) \
+    X("unique", -6, UNIQSW) \
+    X("nounique", -8, NUNIQSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("watch", 0, WATCSW) \
+    X("nowatch", 0, NWATCSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("dashstuffing", -12, BITSTUFFSW) \
+    X("nodashstuffing", -14, NBITSTUFFSW) \
+    X("mail", -4, MAILSW) \
+    X("saml", -4, SAMLSW) \
+    X("send", -4, SENDSW) \
+    X("soml", -4, SOMLSW) \
+    X("client host", -6, CLIESW) \
+    X("server host", 6, SERVSW) \
+    X("snoop", 5, SNOOPSW) \
+    X("sasl", SASLminc(4), SASLSW) \
+    X("nosasl", SASLminc(-6), NOSASLSW) \
+    X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+    X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
+    X("user username", SASLminc(-4), USERSW) \
+    X("attach", 6, ATTACHSW) \
+    X("noattach", 0, NOATTACHSW) \
+    X("attachformat", 7, ATTACHFORMATSW) \
+    X("port server-port-name/number", 4, PORTSW) \
+    X("tls", TLSminc(-3), TLSSW) \
+    X("notls", TLSminc(-5), NTLSSW) \
+    X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+    X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SEND);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SEND, switches);
+#undef X
+
+#define USE_SWITCHES \
+    X("no", 0, NOSW) \
+    X("yes", 0, YESW) \
+    X("list", 0, LISTDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(USE);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(USE, anyl);
+#undef X
 
 extern int debugsw;            /* from sendsbr.c */
 extern int forwsw;
index 849421647bcb4d8420a2663be9ca6142effa6cbe..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
index 869fa17f81a3a4ca51816059451d6e597e44af33..1c30dfc528a48697acf29318aa04dc1c6efe5cba 100644 (file)
 #include <utmpx.h>
 #endif /* HAVE_GETUTXENT */
 
-static struct swit switches[] = {
-#define        ADDRSW         0
-    { "addr address", 0 },
-#define        USERSW         1
-    { "user name", 0 },
-#define        FILESW         2
-    { "file file", 0 },
-#define        SENDERSW       3
-    { "sender address", 0 },
-#define        MAILBOXSW      4
-    { "mailbox file", 0 },
-#define        HOMESW         5
-    { "home directory", -4 },
-#define        INFOSW         6
-    { "info data", 0 },
-#define        MAILSW         7
-    { "maildelivery file", 0 },
-#define        VERBSW         8
-    { "verbose", 0 },
-#define        NVERBSW        9
-    { "noverbose", 0 },
-#define SUPPRESSDUP   10
-    { "suppressdup", 0 },
-#define NSUPPRESSDUP 11
-    { "nosuppressdup", 0 },
-#define        DEBUGSW       12
-    { "debug", 0 },
-#define VERSIONSW     13
-    { "version", 0 },
-#define        HELPSW        14
-    { "help", 0 },
-    { NULL, 0 }
-};
+#define SLOCAL_SWITCHES \
+    X("addr address", 0, ADDRSW) \
+    X("user name", 0, USERSW) \
+    X("file file", 0, FILESW) \
+    X("sender address", 0, SENDERSW) \
+    X("mailbox file", 0, MAILBOXSW) \
+    X("home directory", -4, HOMESW) \
+    X("info data", 0, INFOSW) \
+    X("maildelivery file", 0, MAILSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("suppressdup", 0, SUPPRESSDUP) \
+    X("nosuppressdup", 0, NSUPPRESSDUP) \
+    X("debug", 0, DEBUGSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SLOCAL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SLOCAL, switches);
+#undef X
 
 static int globbed = 0;                /* have we built "vars" table yet?        */
 static int parsed = 0;         /* have we built header field table yet   */
index 024fcf5c4c20643633a52cd8395b56fd9ffc6d14..429f75f9708c7884978a161500079ea920fd6b34 100644 (file)
 #include <h/tws.h>
 #include <h/utils.h>
 
-static struct swit switches[] = {
-#define DATESW                 0
-     { "datefield field", 0 },
-#define        TEXTSW                 1
-     { "textfield field", 0 },
-#define        NSUBJSW                2
-     { "notextfield", 0 },
-#define SUBJSW                 3
-     { "subject", -3 },                   /* backward-compatibility */
-#define LIMSW                  4
-     { "limit days", 0 },
-#define        NLIMSW                 5
-     { "nolimit", 0 },
-#define VERBSW                 6
-     { "verbose", 0 },
-#define NVERBSW                7
-     { "noverbose", 0 },
-#define ALLMSGS                8
-     { "all", 0 },
-#define NALLMSGS               9
-     { "noall", 0 },
-#define CHECKSW               10
-     { "check", 0 },
-#define NCHECKSW              11
-     { "nocheck", 0 },
-#define VERSIONSW             12
-     { "version", 0 },
-#define HELPSW                13
-     { "help", 0 },
-     { NULL, 0 }
-};
+#define SORTM_SWITCHES \
+    X("datefield field", 0, DATESW) \
+    X("textfield field", 0, TEXTSW) \
+    X("notextfield", 0, NSUBJSW) \
+    X("subject", -3, SUBJSW) /* backward-compatibility */ \
+    X("limit days", 0, LIMSW) \
+    X("nolimit", 0, NLIMSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("all", 0, ALLMSGS) \
+    X("noall", 0, NALLMSGS) \
+    X("check", 0, CHECKSW) \
+    X("nocheck", 0, NCHECKSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SORTM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SORTM, switches);
+#undef X
 
 struct smsg {
     int s_msg;
index 4fde61bb04cab802bec908e01ed74fe4187a09a2..82c7db583386c23fef8ebeba4528bd18ab904556 100644 (file)
 #include <h/mime.h>
 #include <h/mhparse.h>
 
-static struct swit switches[] = {
-#define        TOSW                    0
-    { "to mailpath", 0 },
-#define        FROMSW                  1
-    { "from mailpath", 0 },
-#define        SUBJECTSW               2
-    { "subject subject", 0 },
-#define        PARAMSW                 3
-    { "parameters arguments", 0 },
-#define        DESCRIPTSW              4
-    { "description text", 0 },
-#define        COMMENTSW               5
-    { "comment text", 0 },
-#define        DELAYSW                 6
-    { "delay seconds", 0 },
-#define        VERBSW                  7
-    { "verbose", 0 },
-#define        NVERBSW                 8
-    { "noverbose", 0 },
-#define VERSIONSW               9
-    { "version", 0 },
-#define        HELPSW                 10
-    { "help", 0 },
-#define DEBUGSW                11
-    { "debug", -5 },
-    { NULL, 0 }
-};
+#define VIAMAIL_SWITCHES \
+    X("to mailpath", 0, TOSW) \
+    X("from mailpath", 0, FROMSW) \
+    X("subject subject", 0, SUBJECTSW) \
+    X("parameters arguments", 0, PARAMSW) \
+    X("description text", 0, DESCRIPTSW) \
+    X("comment text", 0, COMMENTSW) \
+    X("delay seconds", 0, DELAYSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("debug", -5, DEBUGSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(VIAMAIL);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(VIAMAIL, switches);
+#undef X
 
 extern int debugsw;
 extern int splitsw;
index 389053727c45213dcdfc0c525e39c41a2a5c358f..86ff81df035adbc90bd090de4225a94e9a4524cb 100644 (file)
 #include <h/mime.h>
 #include <h/utils.h>
 
-static struct swit whatnowswitches[] = {
-#define        DFOLDSW                 0
-    { "draftfolder +folder", 0 },
-#define        DMSGSW                  1
-    { "draftmessage msg", 0 },
-#define        NDFLDSW                 2
-    { "nodraftfolder", 0 },
-#define        EDITRSW                 3
-    { "editor editor", 0 },
-#define        NEDITSW                 4
-    { "noedit", 0 },
-#define        PRMPTSW                 5
-    { "prompt string", 4 },
-#define VERSIONSW               6
-    { "version", 0 },
-#define        HELPSW                  7
-    { "help", 0 },
-#define        ATTACHSW                8
-    { "attach header-field-name", 0 },
-#define NOATTACHSW              9
-    { "noattach", 0 },
-    { NULL, 0 }
-};
+#define WHATNOW_SWITCHES \
+    X("draftfolder +folder", 0, DFOLDSW) \
+    X("draftmessage msg", 0, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("editor editor", 0, EDITRSW) \
+    X("noedit", 0, NEDITSW) \
+    X("prompt string", 4, PRMPTSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("attach header-field-name", 0, ATTACHSW) \
+    X("noattach", 0, NOATTACHSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(WHATNOW);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(WHATNOW, whatnowswitches);
+#undef X
 
 /*
  * Options at the "whatnow" prompt
  */
-static struct swit aleqs[] = {
-#define        EDITSW                         0
-    { "edit [<editor> <switches>]", 0 },
-#define        REFILEOPT                      1
-    { "refile [<switches>] +folder", 0 },
-#define BUILDMIMESW                    2
-    { "mime [<switches>]", 0 },
-#define        DISPSW                         3
-    { "display [<switches>]", 0 },
-#define        LISTSW                         4
-    { "list [<switches>]", 0 },
-#define        SENDSW                         5
-    { "send [<switches>]", 0 },
-#define        PUSHSW                         6
-    { "push [<switches>]", 0 },
-#define        WHOMSW                         7
-    { "whom [<switches>]", 0 },
-#define        QUITSW                         8
-    { "quit [-delete]", 0 },
-#define DELETESW                       9
-    { "delete", 0 },
-#define        CDCMDSW                       10
-    { "cd [directory]", 0 },
-#define        PWDCMDSW                      11
-    { "pwd", 0 },
-#define        LSCMDSW                       12
-    { "ls", 2 },
-#define        ATTACHCMDSW                   13
-    { "attach", 0 },
-#define        DETACHCMDSW                   14
-    { "detach [-n]", 2 },
-#define        ALISTCMDSW                    15
-    { "alist [-ln] ", 2 },
-    { NULL, 0 }
-};
+#define PROMPT_SWITCHES \
+    X("edit [<editor> <switches>]", 0, EDITSW) \
+    X("refile [<switches>] +folder", 0, REFILEOPT) \
+    X("mime [<switches>]", 0, BUILDMIMESW) \
+    X("display [<switches>]", 0, DISPSW) \
+    X("list [<switches>]", 0, LISTSW) \
+    X("send [<switches>]", 0, SENDSW) \
+    X("push [<switches>]", 0, PUSHSW) \
+    X("whom [<switches>]", 0, WHOMSW) \
+    X("quit [-delete]", 0, QUITSW) \
+    X("delete", 0, DELETESW) \
+    X("cd [directory]", 0, CDCMDSW) \
+    X("pwd", 0, PWDCMDSW) \
+    X("ls", 2, LSCMDSW) \
+    X("attach", 0, ATTACHCMDSW) \
+    X("detach [-n]", 2, DETACHCMDSW) \
+    X("alist [-ln] ", 2, ALISTCMDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(PROMPT);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(PROMPT, aleqs);
+#undef X
 
 static char *myprompt = "\nWhat now? ";
 
@@ -992,107 +978,64 @@ check_draft (char *msgnam)
 # define TLSminc(a)   0
 #endif /* TLS_SUPPORT */
 
-static struct swit  sendswitches[] = {
-#define        ALIASW            0
-    { "alias aliasfile", 0 },
-#define        DEBUGSW           1
-    { "debug", -5 },
-#define        FILTSW            2
-    { "filter filterfile", 0 },
-#define        NFILTSW           3
-    { "nofilter", 0 },
-#define        FRMTSW            4
-    { "format", 0 },
-#define        NFRMTSW           5
-    { "noformat", 0 },
-#define        FORWSW            6
-    { "forward", 0 },
-#define        NFORWSW           7
-    { "noforward", 0 },
-#define MIMESW            8
-    { "mime", 0 },
-#define NMIMESW           9
-    { "nomime", 0 },
-#define MSGDSW           10
-    { "msgid", 0 },
-#define NMSGDSW          11
-    { "nomsgid", 0 },
-#define SPSHSW           12
-    { "push", 0 },
-#define NSPSHSW          13
-    { "nopush", 0 },
-#define SPLITSW          14
-    { "split seconds", 0 },
-#define UNIQSW           15
-    { "unique", -6 },
-#define NUNIQSW          16
-    { "nounique", -8 },
-#define VERBSW           17
-    { "verbose", 0 },
-#define NVERBSW          18
-    { "noverbose", 0 },
-#define        WATCSW           19
-    { "watch", 0 },
-#define        NWATCSW          20
-    { "nowatch", 0 },
-#define        WIDTHSW          21
-    { "width columns", 0 },
-#define SVERSIONSW       22
-    { "version", 0 },
-#define        SHELPSW          23
-    { "help", 0 },
-#define BITSTUFFSW       24
-    { "dashstuffing", -12 },
-#define NBITSTUFFSW      25
-    { "nodashstuffing", -14 },
-#define        MAILSW           26
-    { "mail", -4 },
-#define        SAMLSW           27
-    { "saml", -4 },
-#define        SSNDSW           28
-    { "send", -4 },
-#define        SOMLSW           29
-    { "soml", -4 },
-#define        CLIESW           30
-    { "client host", -6 },
-#define        SERVSW           31
-    { "server host", 6 },
-#define        SNOOPSW          32
-    { "snoop", -5 },
-#define SDRFSW           33
-    { "draftfolder +folder", -6 },
-#define SDRMSW           34
-    { "draftmessage msg", -6 },
-#define SNDRFSW          35
-    { "nodraftfolder", -3 },
-#define SASLSW           36
-    { "sasl", SASLminc(-4) },
-#define NOSASLSW         37
-    { "nosasl", SASLminc(-6) },
-#define SASLMXSSFSW      38
-    { "saslmaxssf", SASLminc(-10) },
-#define SASLMECHSW       39
-    { "saslmech", SASLminc(-5) },
-#define USERSW           40
-    { "user", SASLminc(-4) },
-#define SNDATTACHSW       41
-    { "attach file", 6 },
-#define SNDNOATTACHSW     42
-    { "noattach", 0 },
-#define SNDATTACHFORMAT   43
-    { "attachformat", 7 },
-#define PORTSW           44
-    { "port server-port-name/number", 4 },
-#define TLSSW            45
-    { "tls", TLSminc(-3) },
-#define NTLSSW            46
-    { "notls", TLSminc(-5) },
-#define MTSSW            47
-    { "mts smtp|sendmail/smtp|sendmail/pipe", 2 },
-#define MESSAGEIDSW      48
-    { "messageid localname|random", 2 },
-    { NULL, 0 }
-};
+#define SEND_SWITCHES \
+    X("alias aliasfile", 0, ALIASW) \
+    X("debug", -5, DEBUGSW) \
+    X("filter filterfile", 0, FILTSW) \
+    X("nofilter", 0, NFILTSW) \
+    X("format", 0, FRMTSW) \
+    X("noformat", 0, NFRMTSW) \
+    X("forward", 0, FORWSW) \
+    X("noforward", 0, NFORWSW) \
+    X("mime", 0, MIMESW) \
+    X("nomime", 0, NMIMESW) \
+    X("msgid", 0, MSGDSW) \
+    X("nomsgid", 0, NMSGDSW) \
+    X("push", 0, SPSHSW) \
+    X("nopush", 0, NSPSHSW) \
+    X("split seconds", 0, SPLITSW) \
+    X("unique", -6, UNIQSW) \
+    X("nounique", -8, NUNIQSW) \
+    X("verbose", 0, VERBSW) \
+    X("noverbose", 0, NVERBSW) \
+    X("watch", 0, WATCSW) \
+    X("nowatch", 0, NWATCSW) \
+    X("width columns", 0, WIDTHSW) \
+    X("version", 0, SVERSIONSW) \
+    X("help", 0, SHELPSW) \
+    X("dashstuffing", -12, BITSTUFFSW) \
+    X("nodashstuffing", -14, NBITSTUFFSW) \
+    X("mail", -4, MAILSW) \
+    X("saml", -4, SAMLSW) \
+    X("send", -4, SSNDSW) \
+    X("soml", -4, SOMLSW) \
+    X("client host", -6, CLIESW) \
+    X("server host", 6, SERVSW) \
+    X("snoop", -5, SNOOPSW) \
+    X("draftfolder +folder", -6, SDRFSW) \
+    X("draftmessage msg", -6, SDRMSW) \
+    X("nodraftfolder", -3, SNDRFSW) \
+    X("sasl", SASLminc(-4), SASLSW) \
+    X("nosasl", SASLminc(-6), NOSASLSW) \
+    X("saslmaxssf", SASLminc(-10), SASLMXSSFSW) \
+    X("saslmech", SASLminc(-5), SASLMECHSW) \
+    X("user", SASLminc(-4), USERSW) \
+    X("attach file", 6, SNDATTACHSW) \
+    X("noattach", 0, SNDNOATTACHSW) \
+    X("attachformat", 7, SNDATTACHFORMAT) \
+    X("port server-port-name/number", 4, PORTSW) \
+    X("tls", TLSminc(-3), TLSSW) \
+    X("notls", TLSminc(-5), NTLSSW) \
+    X("mts smtp|sendmail/smtp|sendmail/pipe", 2, MTSSW) \
+    X("messageid localname|random", 2, MESSAGEIDSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(SEND);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(SEND, sendswitches);
+#undef X
 
 
 extern int debugsw;            /* from sendsbr.c */
index ad49d86a4ccb8ddb2dbdea95397aeb9426d593c4..3830e5eb07e3a4192090151b79ae98bbd9d2d162 100644 (file)
 # define TLSminc(a)   0
 #endif /* TLS_SUPPORT */
 
-static struct swit switches[] = {
-#define        ALIASW              0
-    { "alias aliasfile", 0 },
-#define        CHKSW               1
-    { "check", 0 },
-#define        NOCHKSW             2
-    { "nocheck", 0 },
-#define        DRAFTSW             3
-    { "draft", 0 },
-#define        DFOLDSW             4
-    { "draftfolder +folder", 6 },
-#define        DMSGSW              5
-    { "draftmessage msg", 6 },
-#define        NDFLDSW             6
-    { "nodraftfolder", 0 },
-#define VERSIONSW           7
-    { "version", 0 },
-#define        HELPSW              8
-    { "help", 0 },
-#define        CLIESW              9
-    { "client host", -6 },
-#define        SERVSW             10
-    { "server host", -6 },
-#define        SNOOPSW            11
-    { "snoop", -5 },
-#define SASLSW             12
-    { "sasl", SASLminc(4) },
-#define SASLMECHSW         13
-    { "saslmech mechanism", SASLminc(-5) },
-#define USERSW             14
-    { "user username", SASLminc(-4) },
-#define PORTSW            15
-    { "port server port name/number", 4 },
-#define TLSSW             16
-    { "tls", TLSminc(-3) },
-#define NTLSSW             17
-    { "notls", TLSminc(-5) },
-#define MTSSW             18
-    { "mts smtp|sendmail/smtp|sendmail/pipe", 0 },
-    { NULL, 0 }
-};
+#define WHOM_SWITCHES \
+    X("alias aliasfile", 0, ALIASW) \
+    X("check", 0, CHKSW) \
+    X("nocheck", 0, NOCHKSW) \
+    X("draft", 0, DRAFTSW) \
+    X("draftfolder +folder", 6, DFOLDSW) \
+    X("draftmessage msg", 6, DMSGSW) \
+    X("nodraftfolder", 0, NDFLDSW) \
+    X("version", 0, VERSIONSW) \
+    X("help", 0, HELPSW) \
+    X("client host", -6, CLIESW) \
+    X("server host", -6, SERVSW) \
+    X("snoop", -5, SNOOPSW) \
+    X("sasl", SASLminc(4), SASLSW) \
+    X("saslmech mechanism", SASLminc(-5), SASLMECHSW) \
+    X("user username", SASLminc(-4), USERSW) \
+    X("port server port name/number", 4, PORTSW) \
+    X("tls", TLSminc(-3), TLSSW) \
+    X("notls", TLSminc(-5), NTLSSW) \
+    X("mts smtp|sendmail/smtp|sendmail/pipe", 0, MTSSW) \
+
+#define X(sw, minchars, id) id,
+DEFINE_SWITCH_ENUM(WHOM);
+#undef X
+
+#define X(sw, minchars, id) { sw, minchars, id },
+DEFINE_SWITCH_ARRAY(WHOM, switches);
+#undef X
 
 
 int