]> diplodocus.org Git - nmh/blobdiff - uip/mhbuildsbr.c
Merge branch 'tmpfiles'
[nmh] / uip / mhbuildsbr.c
index 3cb5f5a6099941f30d71cee21a9973a4830ab15a..70747c85ee93a35fca37d17d698e61367ee9bd38 100644 (file)
@@ -42,12 +42,6 @@ extern int contentidsw;
 extern int rcachesw;   /* mhcachesbr.c */
 extern int wcachesw;   /* mhcachesbr.c */
 
-/*
- * Directory to place tmp files.  This must
- * be set before these routines are called.
- */
-char *tmp;
-
 pid_t xpid = 0;
 
 static char prefix[] = "----- =_aaaaaaaaaa";
@@ -129,7 +123,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];
@@ -236,7 +231,9 @@ build_mime (char *infile, int autobuild, int directives, int header_encoding)
 
                entry = mh_xmalloc(sizeof(*entry));
                entry->filename = getcpy(s);
+               entry->next = NULL;
                free(vp);
+
                if (attach_tail) {
                    attach_tail->next = entry;
                    attach_tail = entry;
@@ -283,9 +280,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 +461,8 @@ finish_field:
     }
 
     /* Build the rest of the header field structures */
-    build_headers (ct);
+    if (! dist)
+       build_headers (ct);
 
     return ct;
 }
@@ -573,8 +574,10 @@ user_content (FILE *in, char *buf, CT *ctp)
        FILE *out;
         char *cp;
 
-        cp = m_mktemp2(NULL, invo_name, NULL, &out);
-        if (cp == NULL) adios("mhbuildsbr", "unable to create temporary file");
+       if ((cp = m_mktemp2(NULL, invo_name, NULL, &out)) == NULL) {
+           adios("mhbuildsbr", "unable to create temporary file in %s",
+                 get_temp_dir());
+       }
 
        /* use a temp file to collect the plain text lines */
        ce->ce_file = add (cp, NULL);
@@ -1133,10 +1136,10 @@ compose_content (CT ct)
            if (!(cp = ci->ci_magic))
                adios (NULL, "internal error(5)");
 
-            tfile = m_mktemp2(NULL, invo_name, NULL, NULL);
-            if (tfile == NULL) {
-                adios("mhbuildsbr", "unable to create temporary file");
-            }
+           if ((tfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) {
+               adios("mhbuildsbr", "unable to create temporary file in %s",
+                     get_temp_dir());
+           }
            ce->ce_file = add (tfile, NULL);
            ce->ce_unlink = 1;