]> diplodocus.org Git - nmh/blobdiff - h/mh.h
More test-mhmail probing.
[nmh] / h / mh.h
diff --git a/h/mh.h b/h/mh.h
index 44fc190737938f0a65456b063ebd845c25caf8c7..253af9cbaa08372826036ef26f14c7bb1f18fdb4 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 {
 #define        UNKWNSW  (-1)   /* from smatch() on unknown switch   */
 
 struct swit {
+
+    /*
+     * Switch name
+     */
+
     char *sw;
 
     /* The minchars field is apparently used like this:
     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;
        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. */
 extern struct swit anoyes[];   /* standard yes/no switches */
 
 #define ATTACHFORMATS 3                /* Number of send attach formats. */
@@ -313,7 +364,6 @@ extern char *catproc;
 extern char *components;
 extern char *context;
 extern char *current;
 extern char *components;
 extern char *context;
 extern char *current;
-extern char *defaulteditor;
 extern char *defaultfolder;
 extern char *digestcomps;
 extern char *distcomps;
 extern char *defaultfolder;
 extern char *digestcomps;
 extern char *distcomps;