]> diplodocus.org Git - nmh/commitdiff
Moved readconfig() of mhn.defaults into construct_build_directive().
authorDavid Levine <levinedl@acm.org>
Fri, 17 Jan 2014 01:55:58 +0000 (19:55 -0600)
committerDavid Levine <levinedl@acm.org>
Fri, 17 Jan 2014 01:55:58 +0000 (19:55 -0600)
This way, platforms that don't define MIMETYPEPROC will display
the proper directive with attach -v.

uip/attach.c

index 333cda663bb00a2e2cfc7665f4b36d5d16d61c9a..2902499706ab536aac55a3b8f76daa808c6ea9bb 100644 (file)
@@ -28,7 +28,6 @@ attach(char *attachment_header_field_name, char *draft_file_name,
     int         length;                 /* of attachment header field name */
     char        *p;                     /* miscellaneous string pointer */
     struct stat st;                     /* file status buffer */
     int         length;                 /* of attachment header field name */
     char        *p;                     /* miscellaneous string pointer */
     struct stat st;                     /* file status buffer */
-    FILE        *fp;                    /* pointer for mhn.defaults */
     FILE        *body_file = NULL;      /* body file pointer */
     FILE        *draft_file;            /* draft file pointer */
     int         field_size;             /* size of header field buffer */
     FILE        *body_file = NULL;      /* body file pointer */
     FILE        *draft_file;            /* draft file pointer */
     int         field_size;             /* size of header field buffer */
@@ -177,11 +176,6 @@ attach(char *attachment_header_field_name, char *draft_file_name,
      * composition file for each.
      */
 
      * composition file for each.
      */
 
-    if ((fp = fopen (p = etcpath ("mhn.defaults"), "r"))) {
-       readconfig ((struct node **) NULL, fp, p, 0);
-       fclose(fp);
-    }
-
     rewind(draft_file);
 
     while (get_line(draft_file, field, field_size) != EOF && *field != '\0' &&
     rewind(draft_file);
 
     while (get_line(draft_file, field, field_size) != EOF && *field != '\0' &&
@@ -404,7 +398,6 @@ construct_build_directive (char *file_name, const char *default_content_type,
     char  cmd[PATH_MAX + 8];       /* file command buffer */
     struct stat st;                /* file status buffer */
     char *p;                       /* miscellaneous temporary variables */
     char  cmd[PATH_MAX + 8];       /* file command buffer */
     struct stat st;                /* file status buffer */
     char *p;                       /* miscellaneous temporary variables */
-    FILE *fp;
     int   c;                       /* current character */
 
     if ((content_type = mime_type (file_name)) == NULL) {
     int   c;                       /* current character */
 
     if ((content_type = mime_type (file_name)) == NULL) {
@@ -417,6 +410,12 @@ construct_build_directive (char *file_name, const char *default_content_type,
          * have the suffix in the field, including the dot.
          */
         struct node *np;          /* context scan node pointer */
          * have the suffix in the field, including the dot.
          */
         struct node *np;          /* context scan node pointer */
+        static FILE *fp = NULL;   /* pointer for mhn.defaults */
+
+        if (fp == NULL  &&  (fp = fopen (p = etcpath ("mhn.defaults"), "r"))) {
+            readconfig ((struct node **) NULL, fp, p, 0);
+            fclose(fp);
+        }
 
         if ((p = strrchr(file_name, '.')) != NULL) {
             for (np = m_defs; np; np = np->n_next) {
 
         if ((p = strrchr(file_name, '.')) != NULL) {
             for (np = m_defs; np; np = np->n_next) {
@@ -441,6 +440,7 @@ construct_build_directive (char *file_name, const char *default_content_type,
      */
     if (content_type == NULL) {
         int  binary; /* binary character found flag */
      */
     if (content_type == NULL) {
         int  binary; /* binary character found flag */
+        FILE *fp;
 
         if ((fp = fopen(file_name, "r")) == (FILE *)0) {
             advise(NULL, "unable to access file \"%s\"", file_name);
 
         if ((fp = fopen(file_name, "r")) == (FILE *)0) {
             advise(NULL, "unable to access file \"%s\"", file_name);
@@ -465,6 +465,7 @@ construct_build_directive (char *file_name, const char *default_content_type,
     switch (attachformat) {
     case 0: {
         struct stat st;
     switch (attachformat) {
     case 0: {
         struct stat st;
+        FILE *fp;
         char m[4];
 
         /* Insert name, file mode, and Content-Id. */
         char m[4];
 
         /* Insert name, file mode, and Content-Id. */