Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / refile.c
1 /* refile.c - refile the draft into another folder */
2 #ifndef lint
3 static char ident[] = "@(#)$Id: refile.c,v 1.2 1992/12/15 00:20:22 jromine Exp $";
4 #endif  /* lint */
5
6 #include "../h/mh.h"
7 #include <stdio.h>
8
9 int     refile (arg, file)
10 register char **arg,
11                *file;
12 {
13     int     pid;
14     register int    vecp;
15     char   *vec[MAXARGS];
16
17     vecp = 0;
18     vec[vecp++] = r1bindex (fileproc, '/');
19     vec[vecp++] = "-nolink";    /* override bad .mh_profile defaults */
20     vec[vecp++] = "-nopreserve";
21     vec[vecp++] = "-file";
22     vec[vecp++] = file;
23
24     if (arg)
25         while (*arg)
26             vec[vecp++] = *arg++;
27     vec[vecp] = NULL;
28
29     m_update ();
30     (void) fflush (stdout);
31
32     switch (pid = vfork ()) {
33         case NOTOK: 
34             advise ("fork", "unable to");
35             return NOTOK;
36
37         case OK: 
38             execvp (fileproc, vec);
39             fprintf (stderr, "unable to exec ");
40             perror (fileproc);
41             _exit (-1);
42
43         default: 
44             return (pidwait (pid, NOTOK));
45     }
46 }