]> diplodocus.org Git - nmh/blobdiff - sbr/ext_hook.c
Add support for RFC-2017, message/external-body content which contains URLs.
[nmh] / sbr / ext_hook.c
index d2288487de99ffac43820cd6e7c4049ac60ad3d1..26f2c1c08d6b745fec482a9bf9d9bdc04b0c4fdf 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id$
+/*
  *
  *     Run a program that hooks into some other system.  The first argument is
  *     name of the hook to use, the second is the full path name of a mail message.
@@ -16,25 +16,27 @@ ext_hook(char *hook_name, char *message_file_name_1, char *message_file_name_2)
     char       *hook;                  /* hook program from context */
     pid_t      pid;                    /* ID of child process */
     int                status;                 /* exit or other child process status */
-    char       *vec[4];                /* argument vector for child process */
+    char       **vec;                  /* argument vector for child process */
+    int                vecp;                   /* Vector index */
+    char       *program;               /* Name of program to execute */
 
     static  int        did_message = 0;        /* set if we've already output a message */
 
     if ((hook = context_find(hook_name)) == (char *)0)
        return (OK);
 
-    switch (pid = vfork()) {
+    switch (pid = fork()) {
     case -1:
        status = NOTOK;
        advise(NULL, "external database may be out-of-date.");
        break;
 
     case 0:
-       vec[0] = r1bindex(hook, '/');
-       vec[1] = message_file_name_1;
-       vec[2] = message_file_name_2;
-       vec[3] = (char *)0;
-       execvp(hook, vec);
+        vec = argsplit(hook, &program, &vecp);
+       vec[vecp++] = message_file_name_1;
+       vec[vecp++] = message_file_name_2;
+       vec[vecp++] = NULL;
+       execvp(program, vec);
        _exit(-1);
        /* NOTREACHED */