]> diplodocus.org Git - nmh/blob - sbr/refile.c
Just reworded the bit about '%s' being safe not to quote (it's only safe not to
[nmh] / sbr / refile.c
1
2 /*
3 * refile.c -- call the "fileproc" to refile the
4 * -- msg or draft into another folder
5 *
6 * $Id$
7 */
8
9 #include <h/mh.h>
10
11
12 int
13 refile (char **arg, char *file)
14 {
15 pid_t pid;
16 register int vecp;
17 char *vec[MAXARGS];
18
19 vecp = 0;
20 vec[vecp++] = r1bindex (fileproc, '/');
21 vec[vecp++] = "-nolink"; /* override bad .mh_profile defaults */
22 vec[vecp++] = "-nopreserve";
23 vec[vecp++] = "-file";
24 vec[vecp++] = file;
25
26 if (arg) {
27 while (*arg)
28 vec[vecp++] = *arg++;
29 }
30 vec[vecp] = NULL;
31
32 context_save(); /* save the context file */
33 fflush(stdout);
34
35 switch (pid = vfork()) {
36 case -1:
37 advise ("fork", "unable to");
38 return -1;
39
40 case 0:
41 execvp (fileproc, vec);
42 fprintf (stderr, "unable to exec ");
43 perror (fileproc);
44 _exit (-1);
45
46 default:
47 return (pidwait (pid, -1));
48 }
49 }