- /*
- * If postproc failed, and we have good fd (which means
- * we pushed), then mail error message (and possibly the
- * draft) back to the user.
- */
- if (fd != NOTOK) {
- alert (drft, fd);
- close (fd);
- } else {
- advise (NULL, "message not delivered to anyone");
- }
- if (annotext && fd2 != NOTOK)
- close (fd2);
- if (distfile) {
- unlink (drft);
- if (rename (backup, drft) == NOTOK)
- advise (drft, "unable to rename %s to", backup);
- }
+ /*
+ ** Suppress Content-Id, insert simple
+ ** Content-Disposition.
+ */
+ fprintf(composition_file,
+ "#%s; name=\"%s\" <>{attachment}",
+ content_type,
+ ((p = strrchr(file_name, '/')) == NULL) ?
+ file_name : p + 1);
+ }
+
+ /* Finish up with the file name. */
+ fprintf(composition_file, " %s\n", file_name);
+
+ return;
+}
+
+/*
+** Annotate original message, and
+** call `postproc' to send message.
+*/
+
+static int
+sendaux(char **vec, int vecp, char *drft, struct stat *st)
+{
+ pid_t child_id;
+ int i, status, fd, fd2;
+ char backup[BUFSIZ], buf[BUFSIZ];
+
+ fd = pushsw ? tmp_fd() : NOTOK;
+ fd2 = NOTOK;
+
+ vec[vecp++] = drft;
+ if (annotext) {
+ if ((fd2 = tmp_fd()) != NOTOK) {
+ vec[vecp++] = "-idanno";
+ snprintf(buf, sizeof(buf), "%d", fd2);
+ vec[vecp++] = buf;
+ } else {
+ admonish(NULL, "unable to create file for annotation list");
+ }
+ }
+ if (distfile && distout(drft, distfile, backup) == NOTOK)
+ done(1);
+ vec[vecp] = NULL;
+
+ for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++)
+ sleep(5);
+
+ switch (child_id) {
+ case -1:
+ /* oops -- fork error */
+ adios("fork", "unable to");
+ break; /* NOT REACHED */
+
+ case 0:
+ /*
+ ** child process -- send it
+ **
+ ** If fd is ok, then we are pushing and fd points to temp
+ ** file, so capture anything on stdout and stderr there.
+ */
+ if (fd != NOTOK) {
+ dup2(fd, fileno(stdout));
+ dup2(fd, fileno(stderr));
+ close(fd);
+ }
+ execvp(postproc, vec);
+ fprintf(stderr, "unable to exec ");
+ perror(postproc);
+ _exit(-1);
+ break; /* NOT REACHED */
+
+ default:
+ /*
+ ** parent process -- wait for it
+ */
+ if ((status = pidwait(child_id, NOTOK)) == OK) {
+ if (annotext && fd2 != NOTOK)
+ anno(fd2, st);
+ } else {
+ /*
+ ** If postproc failed, and we have good fd (which
+ ** means we pushed), then mail error message
+ ** (and possibly the draft) back to the user.
+ */
+ if (fd != NOTOK) {
+ alert(drft, fd);
+ close(fd);
+ } else {
+ advise(NULL, "message not delivered to anyone");
+ }
+ if (annotext && fd2 != NOTOK)
+ close(fd2);
+ if (distfile) {
+ unlink(drft);
+ if (rename(backup, drft) == NOTOK)
+ advise(drft, "unable to rename %s to",
+ backup);
+ }
+ }
+ break;