Annotations will always be done inplace from now on.
[mmh] / uip / send.c
index 2cf9757..3055df7 100644 (file)
@@ -29,7 +29,6 @@
 
 int debugsw = 0;  /* global */
 int forwsw  = 1;
-int inplace = 1;
 int pushsw  = 0;
 int verbsw  = 0;
 char *altmsg   = NULL;
@@ -55,8 +54,8 @@ static int sendsbr(char **, int, char *, struct stat *, int);
 static void armed_done(int) NORETURN;
 static void alert(char *, int);
 static int tmp_fd(void);
-static void anno(int, struct stat *);
-static void annoaux(int);
+static void anno(struct stat *);
+static void annoaux(void);
 static int sendaux(char **, int, char *, struct stat *);
 static int attach(char *);
 static void clean_up_temporary_files(void);
@@ -260,9 +259,6 @@ main(int argc, char **argv)
        if (!(annotext = getenv("mhannotate")) || !*annotext) {
                annotext = NULL;
        }
-       if (annotext && ((cp = getenv("mhinplace")) && *cp)) {
-               inplace = atoi(cp);
-       }
        if (!(altmsg = getenv("mhaltmsg")) || !*altmsg) {
                altmsg = NULL;  /* used by dist interface - see below */
        }
@@ -648,16 +644,16 @@ static int
 sendaux(char **vec, int vecp, char *drft, struct stat *st)
 {
        pid_t child_id;
-       int i, status, fd, fd2;
+       int i, status, fd;
        char backup[BUFSIZ];
 
+       /*
+       ** fd collects the output of postproc, and is used for the
+       ** failure notice if we need to send one in alert().
+       */
        fd = pushsw ? tmp_fd() : NOTOK;
-       fd2 = NOTOK;
 
        vec[vecp++] = drft;
-       if (annotext && (fd2 = tmp_fd()) == NOTOK) {
-               admonish(NULL, "unable to create file for annotation list");
-       }
        if (distfile && distout(drft, distfile, backup) == NOTOK) {
                done(1);
        }
@@ -666,7 +662,6 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
        for (i = 0; (child_id = fork()) == NOTOK && i < 5; i++) {
                sleep(5);
        }
-
        switch (child_id) {
        case -1:
                /* oops -- fork error */
@@ -694,8 +689,9 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
        default:
                /* parent process -- wait for it */
                if ((status = pidwait(child_id, NOTOK)) == OK) {
-                       if (annotext && fd2 != NOTOK)
-                               anno(fd2, st);
+                       if (annotext) {
+                               anno(st);
+                       }
                } else {
                        /*
                        ** If postproc failed, and we have good fd (which
@@ -708,9 +704,6 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st)
                        } else {
                                advise(NULL, "message not delivered to anyone");
                        }
-                       if (annotext && fd2 != NOTOK) {
-                               close(fd2);
-                       }
                        if (distfile) {
                                unlink(drft);
                                if (rename(backup, drft) == NOTOK) {
@@ -812,7 +805,7 @@ tmp_fd(void)
 
 
 static void
-anno(int fd, struct stat *st)
+anno(struct stat *st)
 {
        pid_t child_id;
        sigset_t set, oset;
@@ -849,7 +842,7 @@ anno(int fd, struct stat *st)
                sigaddset(&set, SIGTERM);
                SIGPROCMASK(SIG_BLOCK, &set, &oset);
 
-               annoaux(fd);
+               annoaux();
                if (child_id == OK) {
                        _exit(0);
                }
@@ -861,19 +854,17 @@ anno(int fd, struct stat *st)
                break;
 
        default:  /* no waiting... */
-               close(fd);
                break;
        }
 }
 
 
 static void
-annoaux(int fd)
+annoaux(void)
 {
        int fd2, fd3, msgnum;
        char *cp, *folder, *maildir;
-       char buffer[BUFSIZ], **ap;
-       FILE *fp;
+       char **ap;
        struct msgs *mp;
 
        if (!(folder = getenv("mhfolder")) || !*folder) {
@@ -931,33 +922,17 @@ annoaux(int fd)
                goto oops;
        }
 
-       lseek(fd, (off_t) 0, SEEK_SET);
-       if ((fp = fdopen(fd, "r")) == NULL) {
-               if (debugsw) {
-                       admonish(NULL, "unable to fdopen annotation list");
-               }
-               goto oops;
-       }
-       cp = NULL;
-       while (fgets(buffer, sizeof(buffer), fp) != NULL) {
-               cp = add(buffer, cp);
-       }
-       fclose(fp);
-
        if (debugsw) {
-               advise(NULL, "annotate%s with %s: \"%s\"",
-                               inplace ? " inplace" : "", annotext, cp);
+               advise(NULL, "annotate as `%s'", annotext);
        }
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
                if (is_selected(mp, msgnum)) {
                        if (debugsw) {
                                advise(NULL, "annotate message %d", msgnum);
                        }
-                       annotate(m_name(msgnum), annotext, cp, inplace,
-                                       1, -2, 0);
+                       annotate(m_name(msgnum), annotext, NULL, 1, -2, 0);
                }
        }
-       free(cp);
 
 oops:
        folder_free(mp);