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);
case REFILEOPT:
/* Refile the draft */
- if (refile(++argp, drft) == 0)
+ if (refile(++argp, drft) == 0) {
done(0);
+ }
break;
case CDCMDSW:
default:
if ((status = pidwait(pid, NOTOK))) {
- if (((status & 0xff00) != 0xff00)
- && (!reedit || (status & 0x00ff))) {
- if (!use && (status & 0xff00) && (rename(file, cp = m_backup (file)) != NOTOK)) {
+ if (((status & 0xff00) != 0xff00) &&
+ (!reedit || (status & 0x00ff))) {
+ if (!use && (status & 0xff00) && (rename(file, cp = m_backup(file)) != NOTOK)) {
advise(NULL, "problems with edit--draft left in %s", cp);
} else {
advise(NULL, "problems with edit--%s preserved", file);
/*
+** 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
*/