int mhlsbr(int, char **, FILE *(*)(char *));
int distout (char *, char *, char *);
void replout (FILE *, char *, char *, struct msgs *, int,
- int, char *, char *, char *);
+ int, char *, char *, char *, int);
void set_endian(void);
int sc_hardcopy(void);
int sc_length(void);
{ "atfile", 0 },
#define NOATFILESW 30
{ "noatfile", 0 },
+#define FMTPROCSW 31
+ { "fmtproc program", 0 },
+#define NFMTPROCSW 32
+ { "nofmtproc", 0 },
{ NULL, 0 }
};
int anot = 0, inplace = 1;
int nedit = 0, nwhat = 0;
int atfile = 1;
+ int fmtproc = -1;
char *cp, *cwd, *dp, *maildir, *file = NULL;
char *folder = NULL, *msg = NULL, *dfolder = NULL;
char *dmsg = NULL, *ed = NULL, drft[BUFSIZ], buf[BUFSIZ];
case NOATFILESW:
atfile = 0;
continue;
+
+ case FMTPROCSW:
+ if (!(formatproc = *argp++) || *formatproc == '-')
+ adios (NULL, "missing argument to %s", argp[-2]);
+ fmtproc = 1;
+ continue;
+ case NFMTPROCSW:
+ fmtproc = 0;
+ continue;
}
}
if (*cp == '+' || *cp == '@') {
form = etcpath (replcomps);
}
- replout (in, msg, drft, mp, outputlinelen, mime, form, filter, fcc);
+ replout (in, msg, drft, mp, outputlinelen, mime, form, filter,
+ fcc, fmtproc);
fclose (in);
if (nwhat)
* static prototypes
*/
static int insert (struct mailname *);
-static void replfilter (FILE *, FILE *, char *);
+static void replfilter (FILE *, FILE *, char *, int);
void
replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
- int mime, char *form, char *filter, char *fcc)
+ int mime, char *form, char *filter, char *fcc, int fmtproc)
{
NMH_UNUSED (msg);
if (ferror (out))
adios (drft, "error writing");
- replfilter (inb, out, filter);
+ replfilter (inb, out, filter, fmtproc);
} else if (mime && mp) {
fprintf (out, "#forw [original message] +%s %s\n",
mp->foldpath, m_name (mp->lowsel));
*/
static void
-replfilter (FILE *in, FILE *out, char *filter)
+replfilter (FILE *in, FILE *out, char *filter, int fmtproc)
{
int pid;
char *mhl;
char *errstr;
+ char *arglist[7];
if (filter == NULL)
return;
dup2 (fileno (out), fileno (stdout));
closefds (3);
- execlp (mhlproc, mhl, "-form", filter, "-noclear", NULL);
+ arglist[0] = mhl;
+ arglist[1] = "-form";
+ arglist[2] = filter;
+ arglist[3] = "-noclear";
+
+ switch (fmtproc) {
+ case 1:
+ arglist[4] = "-fmtproc";
+ arglist[5] = formatproc;
+ arglist[6] = NULL;
+ break;
+ case 0:
+ arglist[4] = "-nofmtproc";
+ arglist[5] = NULL;
+ break;
+ default:
+ arglist[4] = NULL;
+ }
+
+ execvp (mhlproc, arglist);
errstr = strerror(errno);
write(2, "unable to exec ", 15);
write(2, mhlproc, strlen(mhlproc));