]> diplodocus.org Git - nmh/blob - sbr/refile.c
Make the test suite work on systems other than Linux. Still needs work.
[nmh] / sbr / refile.c
1
2 /*
3 * refile.c -- call the "fileproc" to refile the
4 * -- msg or draft into another folder
5 *
6 * This code is Copyright (c) 2002, by the authors of nmh. See the
7 * COPYRIGHT file in the root directory of the nmh distribution for
8 * complete copyright information.
9 */
10
11 #include <h/mh.h>
12
13
14 int
15 refile (char **arg, char *file)
16 {
17 pid_t pid;
18 register int vecp;
19 char *vec[MAXARGS];
20
21 vecp = 0;
22 vec[vecp++] = r1bindex (fileproc, '/');
23 vec[vecp++] = "-nolink"; /* override bad .mh_profile defaults */
24 vec[vecp++] = "-nopreserve";
25 vec[vecp++] = "-file";
26 vec[vecp++] = file;
27
28 if (arg) {
29 while (*arg)
30 vec[vecp++] = *arg++;
31 }
32 vec[vecp] = NULL;
33
34 context_save(); /* save the context file */
35 fflush(stdout);
36
37 switch (pid = vfork()) {
38 case -1:
39 advise ("fork", "unable to");
40 return -1;
41
42 case 0:
43 execvp (fileproc, vec);
44 fprintf (stderr, "unable to exec ");
45 perror (fileproc);
46 _exit (-1);
47
48 default:
49 return (pidwait (pid, -1));
50 }
51 }