]> diplodocus.org Git - nmh/blobdiff - uip/burst.c
More test-mhmail probing.
[nmh] / uip / burst.c
index 980972e698a97ec9c8791c1c616bff75b93ddae3..0b4a240921eac666a11c7ac2fd96628898fe56ee 100644 (file)
@@ -8,26 +8,25 @@
  */
 
 #include <h/mh.h>
  */
 
 #include <h/mh.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 }
-};
+#include <h/utils.h>
+
+#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;
 
 struct smsg {
     off_t s_start;
@@ -56,9 +55,10 @@ int
 main (int argc, char **argv)
 {
     int inplace = 0, quietsw = 0, verbosw = 0;
 main (int argc, char **argv)
 {
     int inplace = 0, quietsw = 0, verbosw = 0;
-    int msgp = 0, hi, msgnum, numburst;
+    int hi, msgnum, numburst;
     char *cp, *maildir, *folder = NULL, buf[BUFSIZ];
     char *cp, *maildir, *folder = NULL, buf[BUFSIZ];
-    char **argp, **arguments, *msgs[MAXARGS];
+    char **argp, **arguments;
+    struct msgs_array msgs = { 0, 0, NULL };
     struct smsg *smsgs;
     struct msgs *mp;
 
     struct smsg *smsgs;
     struct msgs *mp;
 
@@ -86,10 +86,10 @@ main (int argc, char **argv)
                snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
                        invo_name);
                print_help (buf, switches, 1);
                snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]",
                        invo_name);
                print_help (buf, switches, 1);
-               done (1);
+               done (0);
            case VERSIONSW:
                print_version(invo_name);
            case VERSIONSW:
                print_version(invo_name);
-               done (1);
+               done (0);
 
            case INPLSW: 
                inplace++;
 
            case INPLSW: 
                inplace++;
@@ -119,14 +119,14 @@ main (int argc, char **argv)
            else
                folder = pluspath (cp);
        } else {
            else
                folder = pluspath (cp);
        } else {
-           msgs[msgp++] = cp;
+           app_msgarg(&msgs, cp);
        }
     }
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
        }
     }
 
     if (!context_find ("path"))
        free (path ("./", TFOLDER));
-    if (!msgp)
-       msgs[msgp++] = "cur";
+    if (!msgs.size)
+       app_msgarg(&msgs, "cur");
     if (!folder)
        folder = getfolder (1);
     maildir = m_maildir (folder);
     if (!folder)
        folder = getfolder (1);
     maildir = m_maildir (folder);
@@ -143,8 +143,8 @@ main (int argc, char **argv)
        adios (NULL, "no messages in %s", folder);
 
     /* parse all the message ranges/sequences and set SELECTED */
        adios (NULL, "no messages in %s", folder);
 
     /* parse all the message ranges/sequences and set SELECTED */
-    for (msgnum = 0; msgnum < msgp; msgnum++)
-       if (!m_convert (mp, msgs[msgnum]))
+    for (msgnum = 0; msgnum < msgs.size; msgnum++)
+       if (!m_convert (mp, msgs.msgs[msgnum]))
            done (1);
     seq_setprev (mp);  /* set the previous-sequence */
 
            done (1);
     seq_setprev (mp);  /* set the previous-sequence */