From: Ken Hornstein Date: Sat, 18 Jan 2014 06:17:12 +0000 (-0500) Subject: Beginning of work to run mhbuild always. A bit more complicated than I X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/521674623 Beginning of work to run mhbuild always. A bit more complicated than I originally expected. --- diff --git a/h/prototypes.h b/h/prototypes.h index 97f0544e..a8f6d468 100644 --- a/h/prototypes.h +++ b/h/prototypes.h @@ -336,7 +336,7 @@ int sc_length(void); int sc_width(void); int build_form (char *, char *, int *, char *, char *, char *, char *, char *, char *); -int sendsbr (char **, int, char *, char *, struct stat *, int, char *, int); +int sendsbr (char **, int, char *, char *, struct stat *, int); int SOprintf (char *, ...); int what_now (char *, int, int, char *, char *, int, struct msgs *, char *, int, char *, int); diff --git a/uip/send.c b/uip/send.c index e7ca7157..31718392 100644 --- a/uip/send.c +++ b/uip/send.c @@ -117,8 +117,6 @@ main (int argc, char **argv) char *msgs[MAXARGS], **vec; struct msgs *mp; struct stat st; - char *attach = NMH_ATTACH_HEADER; /* header field name for attachments */ - int attachformat = 1; /* mhbuild format specifier for attachments */ #ifdef LOCALE setlocale(LC_ALL, ""); @@ -273,26 +271,14 @@ main (int argc, char **argv) continue; case ATTACHSW: - if (!(attach = *argp++) || *attach == '-') - adios (NULL, "missing argument to %s", argp[-2]); + advise(NULL, "The -attach switch is deprecated"); continue; case NOATTACHSW: - attach = NULL; + advise(NULL, "The -noattach switch is deprecated"); continue; case ATTACHFORMATSW: - if (! *argp || **argp == '-') - adios (NULL, "missing argument to %s", argp[-1]); - else { - attachformat = atoi (*argp); - if (attachformat < 0 || - attachformat > ATTACHFORMATS - 1) { - advise (NULL, "unsupported attachformat %d", - attachformat); - continue; - } - } - ++argp; + advise(NULL, "The -attachformat switch is deprecated"); continue; } } else { @@ -440,8 +426,7 @@ go_to_it: closefds (3); for (msgnum = 0; msgnum < msgp; msgnum++) { - switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1, attach, - attachformat)) { + switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1)) { case DONE: done (++status); case NOTOK: diff --git a/uip/sendsbr.c b/uip/sendsbr.c index 2b946689..c90b88b7 100644 --- a/uip/sendsbr.c +++ b/uip/sendsbr.c @@ -14,6 +14,7 @@ #include #include #include +#include #ifdef HAVE_SYS_TIME_H # include @@ -34,12 +35,6 @@ char *distfile = NULL; static jmp_buf env; -/* - * external prototypes - */ -int sendsbr (char **, int, char *, char *, struct stat *, int, char *, int); -char *getusername (void); - /* * static prototypes */ @@ -58,47 +53,39 @@ static int sendaux (char **, int, char *, char *, struct stat *); int sendsbr (char **vec, int vecp, char *program, char *drft, struct stat *st, - int rename_drft, char *attachment_header_field_name, int attachformat) + int rename_drft) { - int status; + int status, i; + pid_t child; char buffer[BUFSIZ], file[BUFSIZ]; struct stat sts; - char *original_draft; /* name of original draft file */ - char *p; /* string pointer for building file name */ - char composition_file_name[PATH_MAX + 1]; /* name of mhbuild composition temporary file */ - char body_file_name[PATH_MAX + 1]; /* name of temporary file for body content */ - - /* - * Save the original name of the draft file. The name of the draft file is changed - * to a temporary file containing the built MIME message if there are attachments. - * We need the original name so that it can be renamed after the message is sent. - */ - - original_draft = drft; + char **buildvec, *buildprogram; /* - * There might be attachments if a header field name for attachments is supplied. - * Convert the draft to a MIME message. Use the mhbuild composition file for the - * draft if there was a successful conversion because that now contains the MIME - * message. A nice side effect of this is that it leaves the original draft file - * untouched so that it can be retrieved and modified if desired. + * Run the mimebuildproc (which is by default mhbuild) on the message + * with the addition of the "-auto" flag */ - if (attachment_header_field_name != (char *)0) { - switch (attach(attachment_header_field_name, drft, - body_file_name, sizeof body_file_name, - composition_file_name, sizeof composition_file_name, - attachformat)) { - case OK: - drft = composition_file_name; - break; + switch (child = fork()) { + case NOTOK: + adios("fork", "unable to"); + break; - case NOTOK: - return (NOTOK); + case OK: + buildvec = argsplit(buildmimeproc, &buildprogram, &i); + buildvec[i++] = "-auto"; + buildvec[i++] = drft; + buildvec[i] = NULL; + execvp(buildprogram, buildvec); + fprintf(stderr, "unable to exec "); + perror(buildmimeproc); + _exit(-1); + break; - case DONE: - break; - } + default: + if (pidXwait(child, buildmimeproc)) + return NOTOK; + break; } done=armed_done; @@ -131,7 +118,7 @@ sendsbr (char **vec, int vecp, char *program, char *drft, struct stat *st, /* rename the original draft */ if (rename_drft && status == OK && - rename (original_draft, strncpy (buffer, m_backup (original_draft), sizeof(buffer))) == NOTOK) + rename (drft, strncpy (buffer, m_backup (drft), sizeof(buffer))) == NOTOK) advise (buffer, "unable to rename %s to", drft); break; @@ -144,33 +131,6 @@ sendsbr (char **vec, int vecp, char *program, char *drft, struct stat *st, if (distfile) unlink (distfile); - /* - * Get rid of any temporary files that we created for attachments. Also get rid of - * the renamed composition file that mhbuild leaves as a turd. It looks confusing, - * but we use the body file name to help build the renamed composition file name. - */ - - if (drft == composition_file_name) { - clean_up_temporary_files(body_file_name, composition_file_name); - - if (strlen(composition_file_name) >= sizeof (composition_file_name) - 6) - advise((char *)0, "unable to remove original composition file."); - - else { - if ((p = strrchr(composition_file_name, '/')) == (char *)0) - p = composition_file_name; - else - p++; - - (void)strcpy(body_file_name, p); - *p++ = ','; - (void)strcpy(p, body_file_name); - (void)strcat(p, ".orig"); - - (void)unlink(composition_file_name); - } - } - return status; } diff --git a/uip/viamail.c b/uip/viamail.c index 7c81079d..d57c78e4 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -250,7 +250,7 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw, vec[vecp++] = cp; } - switch (sendsbr (vec, vecp, program, tmpfil, &st, 0, (char *)0, 0)) { + switch (sendsbr (vec, vecp, program, tmpfil, &st, 0)) { case DONE: case NOTOK: status++; diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 7c2c021b..3010bff0 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -1066,9 +1066,6 @@ sendit (char *sp, char **arg, char *file, int pushed) char *cp, buf[BUFSIZ], **argp, *program; char **arguments, *savearg[MAXARGS], **vec; struct stat st; - char *attach = NMH_ATTACH_HEADER;/* attachment header field name */ - int attachformat = 1; /* mhbuild format specifier for - attachments */ #ifndef lint int distsw = 0; @@ -1246,28 +1243,14 @@ sendit (char *sp, char **arg, char *file, int pushed) continue; case SNDATTACHSW: - if (!(attach = *argp++) || *attach == '-') { - advise (NULL, "missing argument to %s", argp[-2]); - return; - } + advise(NULL, "The -attach switch is deprecated"); continue; case SNDNOATTACHSW: - attach = NULL; + advise(NULL, "The -noattach switch is deprecated"); continue; case SNDATTACHFORMAT: - if (! *argp || **argp == '-') - adios (NULL, "missing argument to %s", argp[-1]); - else { - attachformat = atoi (*argp); - if (attachformat < 0 || - attachformat > ATTACHFORMATS - 1) { - advise (NULL, "unsupported attachformat %d", - attachformat); - continue; - } - } - ++argp; + advise(NULL, "The -attachformat switch is deprecated"); continue; } } @@ -1322,7 +1305,7 @@ sendit (char *sp, char **arg, char *file, int pushed) closefds (3); - if (sendsbr (vec, vecp, program, file, &st, 1, attach, attachformat) == OK) + if (sendsbr (vec, vecp, program, file, &st, 1) == OK) done (0); }