"Parse BUFFER as a MIME message.")
+;;; @ Entity Representation and Implementation
+;;;
+
+(defvar mime-entity-implementation-alist nil)
+
+(defsubst mime-find-function (service type)
+ (let ((imps (cdr (assq type mime-entity-implementation-alist))))
+ (if imps
+ (let ((func (cdr (assq service imps))))
+ (unless func
+ (setq func (intern (format "mm%s-%s" type service)))
+ (set-alist 'mime-entity-implementation-alist
+ type (put-alist service func imps))
+ )
+ func)
+ (let ((prefix (format "mm%s" type)))
+ (require (intern prefix))
+ (let ((func (intern (format "%s-%s" prefix service))))
+ (set-alist 'mime-entity-implementation-alist
+ type
+ (list (cons service func)))
+ func)))))
+
+(defun mime-open-entity (type location)
+ "Open an entity and return it.
+TYPE is representation-type.
+LOCATION is location of entity. Specification of it is depended on
+representation-type."
+ (funcall (mime-find-function 'open-entity type) location)
+ )
+
+(defsubst mime-entity-function (entity service)
+ (mime-find-function service
+ (mime-entity-representation-type-internal entity)))
+
+(defun mime-entity-cooked-p (entity)
+ "Return non-nil if contents of ENTITY has been already code-converted."
+ (funcall (mime-entity-function entity 'cooked-p))
+ )
+
+
;;; @ Entity as node of message
;;;
(defalias 'mime-entity-node-id 'mime-entity-node-id-internal)
-(defsubst mime-entity-number (entity)
+(defun mime-entity-number (entity)
"Return entity-number of ENTITY."
(reverse (mime-entity-node-id-internal entity)))
))
)))
-(defsubst mime-find-entity-from-node-id (entity-node-id &optional message)
+(defun mime-find-entity-from-node-id (entity-node-id &optional message)
"Return entity from ENTITY-NODE-ID in MESSAGE.
If MESSAGE is not specified, `mime-message-structure' is used."
(mime-find-entity-from-number (reverse entity-node-id) message))
-(defsubst mime-entity-parent (entity &optional message)
+(defun mime-entity-parent (entity &optional message)
"Return mother entity of ENTITY.
If MESSAGE is not specified, `mime-message-structure' in the buffer of
ENTITY is used."
(set-buffer (mime-entity-buffer entity))
mime-message-structure))))
-(defsubst mime-root-entity-p (entity)
+(defun mime-root-entity-p (entity)
"Return t if ENTITY is root-entity (message)."
(null (mime-entity-node-id entity)))
;;; @ Entity Buffer
;;;
-(defalias 'mime-entity-buffer 'mime-entity-buffer-internal)
-
-(defalias 'mime-entity-point-min 'mime-entity-header-start-internal)
-(defalias 'mime-entity-point-max 'mime-entity-body-end-internal)
-
-(defalias 'mime-entity-header-start 'mime-entity-header-start-internal)
-(defalias 'mime-entity-header-end 'mime-entity-header-end-internal)
-
-(defalias 'mime-entity-body-start 'mime-entity-body-start-internal)
-(defalias 'mime-entity-body-end 'mime-entity-body-end-internal)
+(defun mime-entity-buffer (entity)
+ (or (mime-entity-buffer-internal entity)
+ (funcall (mime-entity-function entity 'entity-buffer) entity)
+ ))
+
+(defun mime-entity-point-min (entity)
+ (funcall (mime-entity-function entity 'entity-point-min) entity)
+ )
+(defun mime-entity-point-max (entity)
+ (funcall (mime-entity-function entity 'entity-point-max) entity)
+ )
+
+(defun mime-entity-header-start (entity)
+ (or (mime-entity-header-start-internal entity)
+ (funcall (mime-entity-function entity 'entity-header-start) entity)
+ ))
+(defsubst mime-entity-header-end (entity)
+ (or (mime-entity-header-end-internal entity)
+ (funcall (mime-entity-function entity 'entity-header-end) entity)
+ ))
+
+(defsubst mime-entity-body-start (entity)
+ (or (mime-entity-body-start-internal entity)
+ (funcall (mime-entity-function entity 'entity-body-start) entity)
+ ))
+(defsubst mime-entity-body-end (entity)
+ (or (mime-entity-body-end-internal entity)
+ (funcall (mime-entity-function entity 'entity-body-end) entity)
+ ))
;;; @ Entity Header
(field-body (cdr (assq field-name header))))
(or field-body
(progn
- (if (save-excursion
- (set-buffer (mime-entity-buffer entity))
- (save-restriction
- (narrow-to-region (mime-entity-header-start entity)
- (mime-entity-header-end entity))
- (setq field-body
- (std11-fetch-field (symbol-name field-name)))
- ))
+ (if (setq field-body
+ (funcall (mime-entity-function entity 'fetch-field)
+ entity (symbol-name field-name)))
(mime-entity-set-original-header-internal
entity (put-alist field-name field-body header))
)