]> diplodocus.org Git - nmh/commitdiff
Beginning of work to run mhbuild always. A bit more complicated than I
authorKen Hornstein <kenh@pobox.com>
Sat, 18 Jan 2014 06:17:12 +0000 (01:17 -0500)
committerKen Hornstein <kenh@pobox.com>
Sat, 18 Jan 2014 06:17:12 +0000 (01:17 -0500)
originally expected.

h/prototypes.h
uip/send.c
uip/sendsbr.c
uip/viamail.c
uip/whatnowsbr.c

index 97f0544..a8f6d46 100644 (file)
@@ -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 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);
 int SOprintf (char *, ...);
 int what_now (char *, int, int, char *, char *,
        int, struct msgs *, char *, int, char *, int);
index e7ca715..3171839 100644 (file)
@@ -117,8 +117,6 @@ main (int argc, char **argv)
     char *msgs[MAXARGS], **vec;
     struct msgs *mp;
     struct stat st;
     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, "");
 
 #ifdef LOCALE
     setlocale(LC_ALL, "");
@@ -273,26 +271,14 @@ main (int argc, char **argv)
                    continue;
                
                case ATTACHSW:
                    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:
                    continue;
                case NOATTACHSW:
-                   attach = NULL;
+                   advise(NULL, "The -noattach switch is deprecated");
                    continue;
 
                case ATTACHFORMATSW:
                    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 {
                    continue;
            }
        } else {
@@ -440,8 +426,7 @@ go_to_it:
     closefds (3);
 
     for (msgnum = 0; msgnum < msgp; msgnum++) {
     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: 
            case DONE: 
                done (++status);
            case NOTOK: 
index 2b94668..c90b88b 100644 (file)
@@ -14,6 +14,7 @@
 #include <h/mime.h>
 #include <h/tws.h>
 #include <h/utils.h>
 #include <h/mime.h>
 #include <h/tws.h>
 #include <h/utils.h>
+#include <h/mts.h>
 
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
 
 #ifdef HAVE_SYS_TIME_H
 # include <sys/time.h>
@@ -34,12 +35,6 @@ char *distfile = NULL;
 
 static jmp_buf env;
 
 
 static jmp_buf env;
 
-/*
- * external prototypes
- */
-int sendsbr (char **, int, char *, char *, struct stat *, int, char *, int);
-char *getusername (void);
-
 /*
  * static prototypes
  */
 /*
  * 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
 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 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;
     }
 
     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 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;
 
            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);
 
     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;
 }
 
     return status;
 }
 
index 7c81079..d57c78e 100644 (file)
@@ -250,7 +250,7 @@ via_mail (char *mailsw, char *subjsw, char *parmsw, char *descsw,
        vec[vecp++] = cp;
     }
 
        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++;
        case DONE:
        case NOTOK:
            status++;
index 7c2c021..3010bff 100644 (file)
@@ -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 *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;
 
 #ifndef        lint
     int        distsw = 0;
@@ -1246,28 +1243,14 @@ sendit (char *sp, char **arg, char *file, int pushed)
                    continue;
 
                case SNDATTACHSW:
                    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:
                    continue;
                case SNDNOATTACHSW:
-                   attach = NULL;
+                   advise(NULL, "The -noattach switch is deprecated");
                    continue;
 
                case SNDATTACHFORMAT:
                    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;
            }
        }
                    continue;
            }
        }
@@ -1322,7 +1305,7 @@ sendit (char *sp, char **arg, char *file, int pushed)
 
     closefds (3);
 
 
     closefds (3);
 
-    if (sendsbr (vec, vecp, program, file, &st, 1, attach, attachformat) == OK)
+    if (sendsbr (vec, vecp, program, file, &st, 1) == OK)
        done (0);
 }
 
        done (0);
 }