]> diplodocus.org Git - nmh/blobdiff - uip/mhbuildsbr.c
Minimized message files reads in m_getfld() when the caller
[nmh] / uip / mhbuildsbr.c
index 4a2c70c7906e10efe20ee2455b78f93caf7b20b6..c7164b32e457ac4c293c5caad9097007c26fe5d7 100644 (file)
@@ -41,8 +41,6 @@ extern int listsw;
 extern int rfc934sw;
 extern int contentidsw;
 
-extern int endian;     /* mhmisc.c */
-
 /* cache policies */
 extern int rcachesw;   /* mhcachesbr.c */
 extern int wcachesw;   /* mhcachesbr.c */
@@ -165,7 +163,8 @@ build_mime (char *infile, int directives)
      * the new MIME message.
      */
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, in)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -181,8 +180,10 @@ build_mime (char *infile, int directives)
 
            /* ignore any Content-Type fields in the header */
            if (!mh_strcasecmp (name, TYPE_FIELD)) {
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, in);
+               }
                goto finish_field;
            }
 
@@ -192,7 +193,8 @@ build_mime (char *infile, int directives)
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
-               state = m_getfld (state, name, buf, sizeof(buf), in);
+               bufsz = sizeof buf;
+               state = m_getfld (state, name, buf, &bufsz, in);
                vp = add (buf, vp);     /* add to previous value */
            }
 
@@ -897,20 +899,19 @@ use_forw:
 static void
 set_id (CT ct, int top)
 {
-    char msgid[BUFSIZ];
+    char contentid[BUFSIZ];
     static int partno;
     static time_t clock = 0;
     static char *msgfmt;
 
     if (clock == 0) {
        time (&clock);
-       snprintf (msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
-               (int) getpid(), (long) clock, LocalName(1));
+       snprintf (contentid, sizeof(contentid), "%s\n", message_id (clock, 1));
        partno = 0;
-       msgfmt = getcpy(msgid);
+       msgfmt = getcpy(contentid);
     }
-    snprintf (msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
-    ct->c_id = getcpy (msgid);
+    snprintf (contentid, sizeof(contentid), msgfmt, top ? 0 : ++partno);
+    ct->c_id = getcpy (contentid);
 }
 
 
@@ -1361,12 +1362,11 @@ scan_content (CT ct)
                continue;
 
            if (contains8bit) {
-               t->tx_charset = CHARSET_UNKNOWN;
                *ap = concat ("charset=", write_charset_8bit(), NULL);
            } else {
-               t->tx_charset = CHARSET_USASCII;
                *ap = add ("charset=us-ascii", NULL);
            }
+           t->tx_charset = CHARSET_SPECIFIED;
 
            cp = strchr(*ap++, '=');
            *ap = NULL;
@@ -1553,11 +1553,6 @@ skip_headers:
     switch (ct->c_encoding) {
     case CE_7BIT:
        /* Nothing to output */
-#if 0
-       np = add (ENCODING_FIELD, NULL);
-       vp = concat (" ", "7bit", "\n", NULL);
-       add_header (ct, np, vp);
-#endif
        break;
 
     case CE_8BIT: