-(defun mime-parse-message (&optional ctl encoding rcnum)
- "Parse current-buffer as a MIME message. [mime-parse.el]"
- (setq ctl (or (mime/Content-Type) ctl))
- (setq encoding (or (mime/Content-Transfer-Encoding) encoding))
- (let ((ctype (car ctl))
- (params (cdr ctl))
- )
- (let ((boundary (assoc "boundary" params)))
- (cond (boundary
- (setq boundary (std11-strip-quoted-string (cdr boundary)))
- (mime-parse-multipart boundary ctype params encoding rcnum)
- )
- ((or (string-equal ctype "message/rfc822")
- (string-equal ctype "message/news")
- )
- (goto-char (point-min))
- (mime::content-info/create rcnum
- (point-min) (point-max)
- ctype 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
- (mime::content-info/create rcnum (point-min) (point-max)
- ctype params encoding nil)
- ))
- )))
+(defun mime-parse-message (&optional default-ctl default-encoding node-id)
+ "Parse current-buffer as a MIME message.
+DEFAULT-CTL is used when an entity does not have valid Content-Type
+field. Its format must be as same as return value of
+mime-{parse|read}-Content-Type."
+ (let* ((content-type (or (mime-read-Content-Type) default-ctl))
+ (encoding (mime-read-Content-Transfer-Encoding default-encoding))
+ (boundary (assoc "boundary"
+ (mime-content-type-parameters content-type))))
+ (cond (boundary
+ (setq boundary (std11-strip-quoted-string (cdr boundary)))
+ (mime-parse-multipart boundary content-type encoding node-id)
+ )
+ ((and (eq (mime-content-type-primary-type content-type)
+ 'message)
+ (memq (mime-content-type-subtype content-type)
+ '(rfc822 news))
+ )
+ (goto-char (point-min))
+ (make-mime-entity node-id (point-min) (point-max)
+ content-type 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 node-id)))
+ ))
+ )
+ (t
+ (make-mime-entity node-id (point-min) (point-max)
+ content-type encoding nil)
+ ))
+ ))
+
+
+;;; @ utilities
+;;;
+
+(defsubst mime-root-entity-p (entity)
+ "Return t if ENTITY is root-entity (message)."
+ (null (mime-entity-node-id entity)))