Folded fileproc to constant `refile'.
[mmh] / uip / whatnow.c
index 6e58052..0576ff8 100644 (file)
@@ -99,6 +99,7 @@ static char *myprompt = "\nWhat now? ";
 static int editfile(char **, char **, char *, int, struct msgs *,
        char *, char *, int);
 static int sendfile(char **, char *, int);
+static int refile(char **, char *);
 static int removefile(char *);
 static void writelscmd(char *, int, char **);
 static void writesomecmd(char *buf, int bufsz, char *cmd, char *trailcmd, char **argp);
@@ -265,8 +266,9 @@ main(int argc, char **argv)
 
                case REFILEOPT:
                        /* Refile the draft */
-                       if (refile(++argp, drft) == 0)
+                       if (refile(++argp, drft) == 0) {
                                done(0);
+                       }
                        break;
 
                case CDCMDSW:
@@ -788,6 +790,47 @@ sendfile(char **arg, char *file, int pushsw)
 
 
 /*
+** refile msg into another folder
+*/
+static int
+refile(char **arg, char *file)
+{
+       pid_t pid;
+       register int vecp;
+       char *vec[MAXARGS];
+
+       vecp = 0;
+       vec[vecp++] = "refile";
+       vec[vecp++] = "-nolink";  /* override bad .mh_profile defaults */
+       vec[vecp++] = "-file";
+       vec[vecp++] = file;
+
+       while (arg && *arg) {
+               vec[vecp++] = *arg++;
+       }
+       vec[vecp] = NULL;
+
+       context_save();  /* save the context file */
+       fflush(stdout);
+
+       switch (pid = fork()) {
+       case -1:
+               advise("fork", "unable to");
+               return -1;
+
+       case 0:
+               execvp(*vec, vec);
+               fprintf(stderr, "unable to exec ");
+               perror(*vec);
+               _exit(-1);
+
+       default:
+               return (pidwait(pid, -1));
+       }
+}
+
+
+/*
 ** Remove the draft file
 */