X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fforw.c;h=57e508f026096be7756354fa6b39198523107007;hb=379b1bf4d085439639e7c535aac08345809dd6aa;hp=b1148b0946ab31999c0d8a503e3b1c182dd4e3b8;hpb=32b2354dbaf4bf934936eb5b102a4a3d2fdd209a;p=mmh diff --git a/uip/forw.c b/uip/forw.c index b1148b0..57e508f 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -20,7 +20,7 @@ static struct swit switches[] = { #define ANNOSW 0 { "annotate", 0 }, #define NANNOSW 1 - { "noannotate", 0 }, + { "noannotate", 2 }, #define EDITRSW 2 { "editor editor", 0 }, #define FORMSW 3 @@ -37,7 +37,7 @@ static struct swit switches[] = { { "Version", 0 }, #define HELPSW 9 { "help", 0 }, -#define BILDSW 12 +#define BILDSW 10 { "build", 5 }, /* interface from mhe */ { NULL, 0 } }; @@ -68,9 +68,7 @@ main(int argc, char **argv) char *fmtstr; int buildsw = 0; -#ifdef LOCALE setlocale(LC_ALL, ""); -#endif invo_name = mhbasename(argv[0]); /* read user profile/context */ @@ -259,25 +257,33 @@ static void 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"); } }