- (setq default-ctl (or (mime-read-Content-Type) default-ctl))
- (let ((primtype (car default-ctl))
- (subtype (car (cdr default-ctl)))
- (params (cdr (cdr default-ctl)))
- (encoding (or (mime/Content-Transfer-Encoding) default-encoding))
- )
- (let ((boundary (assoc "boundary" params)))
- (cond (boundary
- (setq boundary (std11-strip-quoted-string (cdr boundary)))
- (mime-parse-multipart
- boundary
- primtype subtype params encoding rcnum)
- )
- ((and (eq primtype 'message)
- (memq subtype '(rfc822 news))
- )
- (goto-char (point-min))
- (make-mime-entity-info rcnum
- (point-min) (point-max)
- primtype subtype params encoding
- (save-restriction
- (narrow-to-region
- (if (re-search-forward "^$" nil t)
- (1+ (match-end 0))
- (point-min)
- )
- (point-max))
- (list (mime-parse-message
- nil nil (cons 0 rcnum)))
- ))
- )
- (t
- (make-mime-entity-info rcnum (point-min) (point-max)
- primtype subtype params encoding
- nil)
- ))
- )))
+ (let ((header-start (point-min))
+ header-end
+ body-start
+ (body-end (point-max))
+ content-type content-disposition encoding
+ primary-type)
+ (goto-char header-start)
+ (if (re-search-forward "^$" nil t)
+ (setq header-end (match-end 0)
+ body-start (1+ header-end))
+ (setq header-end (point-min)
+ body-start (point-min))
+ )
+ (save-restriction
+ (narrow-to-region header-start header-end)
+ (setq content-type (or (let ((str (std11-fetch-field "Content-Type")))
+ (if str
+ (mime-parse-Content-Type str)
+ ))
+ default-ctl)
+ content-disposition (let ((str (std11-fetch-field
+ "Content-Disposition")))
+ (if str
+ (mime-parse-Content-Disposition str)
+ ))
+ encoding (let ((str (std11-fetch-field
+ "Content-Transfer-Encoding")))
+ (if str
+ (mime-parse-Content-Transfer-Encoding str)
+ default-encoding))
+ primary-type (mime-content-type-primary-type content-type))
+ )
+ (cond ((eq primary-type 'multipart)
+ (mime-parse-multipart header-start header-end
+ body-start body-end
+ content-type content-disposition encoding
+ node-id)
+ )
+ ((and (eq primary-type 'message)
+ (memq (mime-content-type-subtype content-type)
+ '(rfc822 news)
+ ))
+ (make-mime-entity node-id
+ header-start header-end
+ body-start body-end
+ content-type content-disposition encoding
+ (save-restriction
+ (narrow-to-region body-start body-end)
+ (list (mime-parse-message
+ nil nil (cons 0 node-id)))
+ ))
+ )
+ (t
+ (make-mime-entity node-id
+ header-start header-end
+ body-start body-end
+ content-type content-disposition encoding nil)
+ ))
+ ))
+
+
+;;; @ utilities
+;;;
+
+(defsubst mime-root-entity-p (entity)
+ "Return t if ENTITY is root-entity (message)."
+ (null (mime-entity-node-id entity)))