]> diplodocus.org Git - nmh/commitdiff
Add support for not outputting any MIME headers when using dist.
authorKen Hornstein <kenh@pobox.com>
Sun, 19 Jan 2014 06:11:59 +0000 (01:11 -0500)
committerKen Hornstein <kenh@pobox.com>
Sun, 19 Jan 2014 06:11:59 +0000 (01:11 -0500)
h/mhparse.h
uip/mhbuild.c
uip/mhbuildsbr.c
uip/sendsbr.c

index 62e6c0b390983f48b75c51db0c792e0b04140e23..29fc1afe1fcc2fc964e434e942578847c87cc4ba 100644 (file)
@@ -296,6 +296,9 @@ CT parse_mime (char *);
  *               that the composition file is already in MIME format
  *               and will not be processed further.  Otherwise, an
  *               error is generated.
+ * dist                - A flag to indicate if we are being run by "dist".  In
+ *               that case, add no MIME headers to the message.  Existing
+ *               headers will still be encoded by RFC 2047.
  * directives  - A flag to control whether or not build directives are
  *               processed by default.
  * encoding    - The default encoding to use when doing RFC 2047 header
@@ -306,7 +309,8 @@ CT parse_mime (char *);
  * -auto flag is set and a MIME-Version header is encountered, the return
  * value is NULL.
  */
-CT build_mime (char *infile, int autobuild, int directives, int encoding);
+CT build_mime (char *infile, int autobuild, int dist, int directives,
+              int encoding);
 
 int add_header (CT, char *, char *);
 int get_ctinfo (char *, CT, int);
index 18844b56acd95075186c50f0b41fcc3207d29aab..681c4fe8684f1239286c4c753a28314989c68121 100644 (file)
@@ -44,6 +44,7 @@
     X("version", 0, VERSIONSW) \
     X("help", 0, HELPSW) \
     X("debug", -5, DEBUGSW) \
+    X("dist", -4, DISTSW) \
 
 #define X(sw, minchars, id) id,
 DEFINE_SWITCH_ENUM(MHBUILD);
@@ -103,7 +104,7 @@ int list_all_messages (CT *, int, int, int, int);
 int
 main (int argc, char **argv)
 {
-    int sizesw = 1, headsw = 1, directives = 1, autobuild = 0;
+    int sizesw = 1, headsw = 1, directives = 1, autobuild = 0, dist = 0;
     int *icachesw;
     char *cp, buf[BUFSIZ];
     char buffer[BUFSIZ], *compfile = NULL;
@@ -270,6 +271,9 @@ main (int argc, char **argv)
            case DEBUGSW:
                debugsw = 1;
                continue;
+           case DISTSW:
+               dist = 1;
+               continue;
            }
        }
        if (compfile)
@@ -336,7 +340,7 @@ main (int argc, char **argv)
        unlink_infile = 1;
 
        /* build the content structures for MIME message */
-       ct = build_mime (infile, autobuild, directives, header_encoding);
+       ct = build_mime (infile, autobuild, dist, directives, header_encoding);
 
        /*
         * If ct == NULL, that means that -auto was set and a MIME version
@@ -366,7 +370,7 @@ main (int argc, char **argv)
      */
 
     /* build the content structures for MIME message */
-    ct = build_mime (compfile, autobuild, directives, header_encoding);
+    ct = build_mime (compfile, autobuild, dist, directives, header_encoding);
 
     /*
      * If ct == NULL, that means -auto was set and we found a MIME version
index 3cb5f5a6099941f30d71cee21a9973a4830ab15a..840f0467b6fd1ec2d035db3cd8221ff38dd8e696 100644 (file)
@@ -129,7 +129,8 @@ static void directive_pop(void)
  */
 
 CT
-build_mime (char *infile, int autobuild, int directives, int header_encoding)
+build_mime (char *infile, int autobuild, int dist, int directives,
+           int header_encoding)
 {
     int        compnum, state;
     char buf[BUFSIZ], name[NAMESZ];
@@ -283,9 +284,12 @@ finish_field:
      * Now add the MIME-Version header field
      * to the list of header fields.
      */
-    np = add (VRSN_FIELD, NULL);
-    vp = concat (" ", VRSN_VALUE, "\n", NULL);
-    add_header (ct, np, vp);
+
+    if (! dist) {
+       np = add (VRSN_FIELD, NULL);
+       vp = concat (" ", VRSN_VALUE, "\n", NULL);
+       add_header (ct, np, vp);
+    }
 
     /*
      * We initally assume we will find multiple contents in the
@@ -461,7 +465,8 @@ finish_field:
     }
 
     /* Build the rest of the header field structures */
-    build_headers (ct);
+    if (! dist)
+       build_headers (ct);
 
     return ct;
 }
index c90b88b7ec399b6d3fb30b6717f5132d53e924f8..fd80a0f00d84ad00675ca69eeb153b23a3da8612 100644 (file)
@@ -74,6 +74,8 @@ sendsbr (char **vec, int vecp, char *program, char *drft, struct stat *st,
     case OK:
        buildvec = argsplit(buildmimeproc, &buildprogram, &i);
        buildvec[i++] = "-auto";
+       if (distfile)
+           buildvec[i++] = "-dist";
        buildvec[i++] = drft;
        buildvec[i] = NULL;
        execvp(buildprogram, buildvec);