]> diplodocus.org Git - nmh/blobdiff - uip/rcvdist.c
More replacements of mh_strcasecmp() with strcasecmp().
[nmh] / uip / rcvdist.c
index 0052b07b4fbeb558177c6531a13549b733cd791e..6cc8e27764a3c11bac096440985ccb85dab964ca 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] = "";
@@ -39,9 +42,9 @@ int
 main (int argc, char **argv)
 {
     pid_t child_id;
-    int i, vecp = 1;
-    char *addrs = NULL, *cp, *form = NULL, buf[BUFSIZ];
-    char **argp, **arguments, *vec[MAXARGS];
+    int i, vecp;
+    char *addrs = NULL, *cp, *form = NULL, buf[BUFSIZ], *program;
+    char **argp, **arguments, **vec;
     FILE *fp;
     char *tfile = NULL;
 
@@ -55,6 +58,13 @@ main (int argc, char **argv)
     /* read user profile/context */
     context_read();
 
+    /*
+     * Configure this now, since any unknown switches to rcvdist get
+     * sent to postproc
+     */
+
+    vec = argsplit(postproc, &program, &vecp);
+
     mts_init (invo_name);
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
@@ -111,7 +121,6 @@ main (int argc, char **argv)
     if (distout (drft, tmpfil, backup) == NOTOK)
        done (1);
 
-    vec[0] = r1bindex (postproc, '/');
     vec[vecp++] = "-dist";
     vec[vecp++] = drft;
     if ((cp = context_find ("mhlproc"))) {
@@ -126,7 +135,7 @@ main (int argc, char **argv)
        case NOTOK: 
            admonish (NULL, "unable to fork");/* fall */
        case OK: 
-           execvp (postproc, vec);
+           execvp (program, vec);
            fprintf (stderr, "unable to exec ");
            perror (postproc);
            _exit (1);
@@ -232,7 +241,7 @@ finished: ;
     scanl = mh_xmalloc ((size_t) i + 2);
     dat[0] = dat[1] = dat[2] = dat[4] = 0;
     dat[3] = outputlinelen;
-    fmt_scan (fmt, scanl, i + 1, i, dat);
+    fmt_scan (fmt, scanl, i + 1, i, dat, NULL);
     fputs (scanl, out);
 
     if (ferror (out))