X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fwhatnow.c;h=efdf02d4b7176195df17488f47f8398e70205fbd;hb=31dc797eb5178970d68962ca8939da3fd9a8efda;hp=d0b0f93abf190be4eb4d9d2d8255e59d3f78c73b;hpb=b9650770c24af625e4ddc6d791b9d5b652c1e8b2;p=mmh diff --git a/uip/whatnow.c b/uip/whatnow.c index d0b0f93..efdf02d 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -70,23 +70,21 @@ static struct swit aleqs[] = { { "list", 0 }, #define SENDSW 4 { "send []", 0 }, -#define PUSHSW 5 - { "push []", 0 }, -#define QUITSW 6 +#define QUITSW 5 { "quit", 0 }, -#define DELETESW 7 +#define DELETESW 6 { "delete", 0 }, -#define CDCMDSW 8 +#define CDCMDSW 7 { "cd [directory]", 0 }, -#define PWDCMDSW 9 +#define PWDCMDSW 8 { "pwd", 0 }, -#define LSCMDSW 10 +#define LSCMDSW 9 { "ls", 0 }, -#define ATTACHCMDSW 11 +#define ATTACHCMDSW 10 { "attach", 0 }, -#define DETACHCMDSW 12 +#define DETACHCMDSW 11 { "detach [-n]", 0 }, -#define ALISTCMDSW 13 +#define ALISTCMDSW 12 { "alist", 0 }, { NULL, 0 } }; @@ -98,7 +96,8 @@ 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 sendfile(char **, char *); +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); @@ -252,21 +251,16 @@ main(int argc, char **argv) removefile(drft); done(1); - case PUSHSW: - /* Send draft in background */ - if (sendfile(++argp, drft, 1)) - done(1); - break; - case SENDSW: /* Send draft */ - sendfile(++argp, drft, 0); + sendfile(++argp, drft); break; case REFILEOPT: /* Refile the draft */ - if (refile(++argp, drft) == 0) + if (refile(++argp, drft) == 0) { done(0); + } break; case CDCMDSW: @@ -671,9 +665,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); @@ -750,7 +744,7 @@ copyf(char *ifile, char *ofile) */ static int -sendfile(char **arg, char *file, int pushsw) +sendfile(char **arg, char *file) { pid_t child_id; int vecp; @@ -766,8 +760,6 @@ sendfile(char **arg, char *file, int pushsw) case OK: vecp = 0; vec[vecp++] = invo_name; - if (pushsw) - vec[vecp++] = "-push"; if (arg) while (*arg) vec[vecp++] = *arg++; @@ -788,6 +780,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 */