X-Git-Url: http://git.marmaro.de/?p=mmh;a=blobdiff_plain;f=uip%2Fwhatnow.c;h=0576ff84add95b4ca02d6e68690747f5bd2b05aa;hp=d0b0f93abf190be4eb4d9d2d8255e59d3f78c73b;hb=412b2e54251ff6e20537f83b95c8ee76ea8c5c40;hpb=b9650770c24af625e4ddc6d791b9d5b652c1e8b2 diff --git a/uip/whatnow.c b/uip/whatnow.c index d0b0f93..0576ff8 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -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: @@ -671,9 +673,9 @@ editfile(char **ed, char **arg, char *file, int use, struct msgs *mp, 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); @@ -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 */