#include <h/fmt_scan.h>
#include <h/tws.h>
#include <h/utils.h>
-
+#include <unistd.h>
+#include <locale.h>
#define IFORMAT "digest-issue-%s"
#define VFORMAT "digest-volume-%s"
char *fmtstr;
int buildsw = 0;
-#ifdef LOCALE
setlocale(LC_ALL, "");
-#endif
invo_name = mhbasename(argv[0]);
/* read user profile/context */
switch (smatch(++cp, switches)) {
case AMBIGSW:
ambigsw(cp, switches);
- done(1);
+ /* sysexits.h EX_USAGE */
+ exit(1);
case UNKWNSW:
adios(NULL, "-%s unknown", cp);
case HELPSW:
snprintf(buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name);
print_help(buf, switches, 1);
- done(1);
+ exit(0);
case VERSIONSW:
print_version(invo_name);
- done(1);
+ exit(0);
case ANNOSW:
anot++;
adios(NULL, "no messages in %s", folder);
/* parse all the message ranges/sequences and set SELECTED */
- for (msgnum = 0; msgnum < msgp; msgnum++)
- if (!m_convert(mp, msgs[msgnum]))
- done(1);
+ for (msgnum = 0; msgnum < msgp; msgnum++) {
+ if (!m_convert(mp, msgs[msgnum])) {
+ /* sysexits.h EX_USAGE */
+ exit(1);
+ }
+ }
seq_setprev(mp); /* set the previous sequence */
if ((out = creat(drft, m_gmprot())) == NOTOK)
context_save(); /* save the context file */
if (buildsw)
- done(0);
+ exit(0);
what_now(ed, NOUSE, drft, NULL, 0, mp,
anot ? "Forwarded" : NULL, cwd);
- done(1);
+ /* sysexits.h EX_SOFTWARE */
return 1;
}
add_forw_hdr(char *draft)
{
int msgnum;
- char buffer[BUFSIZ];
-
- snprintf(buffer, sizeof buffer, "anno -append -nodate '%s' "
- "-comp '%s' -text '+%s",
- draft, attach_hdr, mp->foldpath);
+ char buf[BUFSIZ];
+ char *vec[MAXARGS];
+ int vecp = 0;
+
+ vec[vecp++] = "anno";
+ vec[vecp++] = "-append";
+ vec[vecp++] = "-nodate";
+ vec[vecp++] = draft;
+ vec[vecp++] = "-comp";
+ vec[vecp++] = attach_hdr;
+ vec[vecp++] = "-text";
+ snprintf(buf, sizeof buf, "+%s", mp->foldpath);
for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
if (!is_selected(mp, msgnum)) {
continue;
}
- /* TODO: Check for buffer length! */
- strcat(buffer, " ");
- strcat(buffer, m_name(msgnum));
- }
- strcat(buffer, "'");
- /* TODO: This check is bad, but better than nothing */
- if (strlen(buffer) > BUFSIZ) {
- adios(NULL, "Too long attachment header line. Forward less messages.");
+ if (strlen(buf) + 1 + strlen(m_name(msgnum)) + 1
+ > sizeof buf) {
+ adios(NULL, "Attachment header line too long. "
+ "Forward less messages.");
+ }
+ strcat(buf, " ");
+ strcat(buf, m_name(msgnum));
}
- if (system(buffer) != 0) {
+ vec[vecp++] = buf;
+ vec[vecp] = NULL;
+ if (execprog(*vec, vec) != 0) {
advise(NULL, "unable to add attachment header");
}
}