]> diplodocus.org Git - nmh/blobdiff - uip/rcvdist.c
Make sure we created the test file even if we don't have iconv support;
[nmh] / uip / rcvdist.c
index c11ac491658aced59243b391d74b88abafeaf6e6..33890d5f786343bc869dc75de4d3ab2fde5ea130 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] = "";
@@ -173,7 +176,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
     char *cp, *scanl, name[NAMESZ], tmpbuf[SBUFSIZ];
     register struct comp *cptr;
     FILE *out;
-    m_getfld_state_t gstate;
+    m_getfld_state_t gstate = 0;
 
     if (!(out = fopen (drft, "w")))
        adios (drft, "unable to create");
@@ -193,10 +196,9 @@ rcvdistout (FILE *inb, char *form, char *addrs)
     if (cptr)
        cptr->c_text = addrs;
 
-    m_getfld_state_init (&gstate);
     for (;;) {
        int msg_count = SBUFSIZ;
-       switch (state = m_getfld (gstate, name, tmpbuf, &msg_count, inb)) {
+       switch (state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb)) {
            case FLD: 
            case FLDPLUS: 
                i = fmt_addcomptext(name, tmpbuf);
@@ -204,7 +206,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
                    char_read += msg_count;
                    while (state == FLDPLUS) {
                        msg_count = SBUFSIZ;
-                       state = m_getfld (gstate, name, tmpbuf, &msg_count, inb);
+                       state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
@@ -212,7 +214,7 @@ rcvdistout (FILE *inb, char *form, char *addrs)
 
                while (state == FLDPLUS) {
                    msg_count = SBUFSIZ;
-                   state = m_getfld (gstate, name, tmpbuf, &msg_count, inb);
+                   state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb);
                }
                break;