*/
/*
-** This program is usually called directly by users, but it is
-** also invoked by the spost program to process an "Fcc", or by
-** comp/repl/forw/dist to refile a draft message.
-*/
-char *fileproc = "refile";
-
-/*
** This is the default program invoked by a "list" or "display" response
** at the "What now?" prompt. It will be given the absolute pathname of
** the message to show. The string ``show -file'' is most likely what you
extern char *digestcomps;
extern char *distcomps;
extern char *draftfolder;
-extern char *fileproc;
extern char *foldprot;
extern char *forwcomps;
extern char *inbox;
char *pwd(void);
char *mhbasename(char *);
void readconfig(struct node **, FILE *, char *, int);
-int refile(char **, char *);
void ruserpass(char *, char **, char **);
int seq_addmsg(struct msgs *, char *, int, int, int);
int seq_addsel(struct msgs *, char *, int, int);
^Draft\-Folder:~^To set the default draft folder
^Editor:~^To override the default editor
^Msg\-Protect:~^To set mode when creating a new message (draft)
-^fileproc:~^Program to refile the message
^whatnowproc:~^Program to ask the \*(lqWhat now?\*(rq questions
.fi
^Draft\-Folder:~^To set the default draft\-folder
^Editor:~^To override the default editor
^Msg\-Protect:~^To set mode when creating a new message (draft)
-^fileproc:~^Program to refile the message
^whatnowproc:~^Program to ask the \*(lqWhat now?\*(rq questions
.fi
user wishes. The default values are given in the examples.
.RE
.PP
-.BR fileproc :
-%bindir%/refile
-.RS 5
-This program is used to refile or link a message to another folder.
-It is used by
-.B post
-to file a copy of a message into a folder given
-by a \*(lqFcc:\*(rq field. It is used by the draft folder facility in
-.BR comp ,
-.BR dist ,
-.BR forw ,
-and
-.B repl
-to refile a draft
-message into another folder. It is used to refile a draft message in
-response to the
-.B refile
-directive at the \*(lqWhat now?\*(rq prompt.
-.RE
-.PP
.BR listproc :
show \-file
.RS 5
^Draft\-Folder:~^To set the default draft\-folder
^Editor:~^To override the default editor
^Msg\-Protect:~^To set mode when creating a new message (draft)
-^fileproc:~^Program to refile the message
^whatnowproc:~^Program to ask the \*(lqWhat now?\*(rq questions
.fi
.PP
For the
.B refile
-response, any valid switch to the
-.I fileproc
+response, any valid switch to
+.B refile
is valid.
.PP
See
^Editor:~^To override the default editor
^<lasteditor>\-next:~^To name an editor to be used after exit
^~^from <lasteditor>
-^fileproc:~^Program to refile the message
^listproc:~^Program to list the contents of a message
.fi
makedir.c mts.c norm_charmap.c \
path.c pidwait.c pidstatus.c \
print_help.c print_sw.c print_version.c \
- putenv.c refile.c mhbasename.c \
+ putenv.c mhbasename.c \
readconfig.c ruserpass.c seq_add.c seq_bits.c \
seq_del.c seq_getnum.c seq_list.c seq_nameok.c \
seq_print.c seq_read.c seq_save.c seq_setcur.c \
{ "backup-prefix", &backup_prefix },
{ "draft-folder", &draftfolder },
{ "altmsg-link", &altmsglink },
- { "fileproc", &fileproc },
{ "listproc", &listproc },
{ "sendmail", &sendmail },
{ "trash-folder", &trashfolder },
+++ /dev/null
-/*
-** refile.c -- call the "fileproc" to refile the
-** -- msg or draft into another folder
-**
-** This code is Copyright (c) 2002, by the authors of nmh. See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-
-
-int
-refile(char **arg, char *file)
-{
- pid_t pid;
- register int vecp;
- char *vec[MAXARGS];
-
- vecp = 0;
- vec[vecp++] = mhbasename(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;
-
- context_save(); /* save the context file */
- fflush(stdout);
-
- switch (pid = fork()) {
- case -1:
- advise("fork", "unable to");
- return -1;
-
- case 0:
- execvp(fileproc, vec);
- fprintf(stderr, "unable to exec ");
- perror(fileproc);
- _exit(-1);
-
- default:
- return (pidwait(pid, -1));
- }
-}
{ "context", &context },
{ "mh-sequences", &mh_seq },
{ "editor", &defaulteditor },
- { "fileproc", &fileproc },
{ "foldprot", &foldprot },
{ "listproc", &listproc },
{ "mimetypequeryproc", &mimetypequeryproc },
folders);
fflush(stdout);
}
- if (strlen(fileproc)+strlen(file)+strlen(folders)+100 > sizeof cmd) {
+ if (100+strlen(file)+strlen(folders) > sizeof cmd) {
adios(NULL, "Too much Fcc data");
}
/* hack: read from /dev/null and refile(1) won't question us */
- snprintf(cmd, sizeof cmd, "</dev/null %s -link -file %s %s",
- fileproc, file, folders);
+ snprintf(cmd, sizeof cmd, "</dev/null refile -link -file '%s' %s",
+ file, folders);
status = system(cmd);
if (status == -1) {
fprintf(stderr, "Skipped %sFcc %s: unable to system().\n",
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:
/*
+** 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
*/