Mercurial > hg > Applications > mh
diff sbr/refile.c @ 0:bce86c4163a3
Initial revision
author | kono |
---|---|
date | Mon, 18 Apr 2005 23:46:02 +0900 |
parents | |
children | 441a2190cfae |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sbr/refile.c Mon Apr 18 23:46:02 2005 +0900 @@ -0,0 +1,49 @@ +/* refile.c - refile the draft into another folder */ +#ifndef lint +static char ident[] = "@(#)$Id$"; +#endif /* lint */ + +#include "../h/mh.h" +#include <stdio.h> +#ifdef UNISTD +#include <unistd.h> +#endif + +int refile (arg, file) +register char **arg, + *file; +{ + int pid; + register int vecp; + char *vec[MAXARGS]; + + vecp = 0; + vec[vecp++] = r1bindex (fileproc, '/'); + vec[vecp++] = "-nolink"; /* override bad .mh_profile defaults */ + vec[vecp++] = "-nopreserve"; + vec[vecp++] = "-file"; + vec[vecp++] = file; + + if (arg) + while (*arg) + vec[vecp++] = *arg++; + vec[vecp] = NULL; + + m_update (); + (void) fflush (stdout); + + switch (pid = vfork ()) { + case NOTOK: + advise ("fork", "unable to"); + return NOTOK; + + case OK: + execvp (fileproc, vec); + fprintf (stderr, "unable to exec "); + perror (fileproc); + _exit (-1); + + default: + return (pidwait (pid, NOTOK)); + } +}