- /*
- * This header field is discarded.
- */
- if (!strcasecmp (name, "Message-ID")) {
- while (state == FLDPLUS)
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
- } else if (uprf (name, XXX_FIELD_PRF)
- || !strcasecmp (name, VRSN_FIELD)
- || !strcasecmp (name, "Subject")
- || !strcasecmp (name, "Encrypted")) {
- /*
- * These header fields are copied to the enclosed
- * header of the first message in the collection
- * of message/partials. For the "Subject" header
- * field, we also record it, so that a modified
- * version of it, can be copied to the header
- * of each messsage/partial in the collection.
- */
- if (!strcasecmp (name, "Subject")) {
- size_t sublen;
-
- strncpy (subject, buffer, BUFSIZ);
- sublen = strlen (subject);
- if (sublen > 0 && subject[sublen - 1] == '\n')
- subject[sublen - 1] = '\0';
- }
-
- dp = add (concat (name, ":", buffer, NULL), dp);
- while (state == FLDPLUS) {
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
- dp = add (buffer, dp);
- }
- } else {
- /*
- * These header fields are copied to the header of
- * each message/partial in the collection.
- */
- cp = add (concat (name, ":", buffer, NULL), cp);
- while (state == FLDPLUS) {
- state = m_getfld (state, name, buffer, sizeof(buffer), in);
- cp = add (buffer, cp);
- }
+ /*
+ ** Allocate a buffer to hold the header components as they're read in.
+ ** This buffer might need to be quite large, so we grow it as needed.
+ */
+ field = (char *)mh_xmalloc(field_size = 256);
+
+ /*
+ ** Scan the draft file for an attachment header field name.
+ ** The existence of one indicates that the
+ ** draft has attachments. Bail out if there are no attachments
+ ** because we're done. Read to the end of the headers even if
+ ** we have no attachments.
+ */
+ length = strlen(attach_hdr);
+
+ has_attachment = 0;
+
+ while (get_line() != EOF && *field != '\0' && *field != '-') {
+ if (strncasecmp(field, attach_hdr, length) == 0 &&
+ field[length] == ':') {
+ has_attachment = 1;