- (or (symbolp field-name)
- (setq field-name (capitalize (capitalize field-name))))
- (cond ((eq field-name 'Content-Type)
- (mime-entity-content-type entity)
- )
- ((eq field-name 'Content-Disposition)
- (mime-entity-content-disposition entity)
- )
- ((eq field-name 'Content-Transfer-Encoding)
- (mime-entity-encoding entity)
- )
- (t
- (let* ((header (mime-entity-parsed-header entity))
- (field (cdr (assq field-name header))))
- (or field
- (let ((field-body (mime-entity-fetch-field entity field-name)))
- (when field-body
- (cond ((memq field-name '(From Resent-From
- To Resent-To
- Cc Resent-Cc
- Bcc Resent-Bcc
- Reply-To Resent-Reply-To))
- (setq field (std11-parse-addresses
- (eword-lexical-analyze field-body)))
- )
- ((eq field-name '(Sender Resent-Sender))
- (setq field (std11-parse-address
- (eword-lexical-analyze field-body)))
- )
- ((memq field-name eword-decode-ignored-field-list)
- (setq field field-body))
- ((memq field-name eword-decode-structured-field-list)
- (setq field (eword-decode-structured-field-body
- field-body)))
- (t
- (setq field (eword-decode-unstructured-field-body
- field-body))
- ))
- (mime-entity-set-parsed-header
- entity (put-alist field-name field header))
- field)))))))
-
-(defun mime-entity-content (entity)
+ (let ((sym (if (symbolp field-name)
+ (prog1
+ field-name
+ (setq field-name (symbol-name field-name)))
+ (intern (capitalize field-name)))))
+ (cond ((eq sym 'Content-Type)
+ (mime-entity-content-type entity)
+ )
+ ((eq sym 'Content-Disposition)
+ (mime-entity-content-disposition entity)
+ )
+ ((eq sym 'Content-Transfer-Encoding)
+ (mime-entity-encoding entity)
+ )
+ (t
+ (let* ((header (mime-entity-parsed-header-internal entity))
+ (field (cdr (assq sym header))))
+ (or field
+ (let ((field-body (mime-entity-fetch-field entity field-name))
+ parser)
+ (when field-body
+ (setq parser
+ (cdr (assq sym mime-field-parser-alist)))
+ (setq field
+ (if parser
+ (funcall parser
+ (eword-lexical-analyze field-body))
+ (mime-decode-field-body field-body sym 'plain)
+ ))
+ (mime-entity-set-parsed-header-internal
+ entity (put-alist sym field header))
+ field))))))))
+
+;; (defun mime-read-field (field-name &optional entity)
+;; (or entity
+;; (setq entity mime-message-structure))
+;; (mime-entity-read-field entity field-name)
+;; )
+;; (make-obsolete 'mime-read-field 'mime-entity-read-field)
+
+(luna-define-generic mime-insert-header (entity &optional invisible-fields
+ visible-fields)
+ "Insert before point a decoded header of ENTITY.")
+
+
+;;; @ Entity Attributes
+;;;
+
+(luna-define-generic mime-entity-name (entity)
+ "Return name of the ENTITY.")
+
+(defun mime-entity-uu-filename (entity)
+ (if (member (mime-entity-encoding entity) mime-uuencode-encoding-name-list)
+ (with-temp-buffer
+ (mime-insert-entity-body entity)
+ (if (re-search-forward "^begin [0-9]+ " nil t)
+ (if (looking-at ".+$")
+ (buffer-substring (match-beginning 0)(match-end 0))
+ )))))
+
+;; unlimited patch by simm-emacs@fan.gr.jp
+;; Mon, 10 Jan 2000 12:59:46 +0900
+(defun mime-entity-filename (entity)
+ "Return filename of ENTITY."
+ (let ((filename
+ (or (mime-entity-uu-filename entity)
+ (mime-content-disposition-filename
+ (mime-entity-content-disposition entity))
+ (cdr (let ((param (mime-content-type-parameters
+ (mime-entity-content-type entity))))
+ (or (assoc "name" param)
+ (assoc "x-name" param))))
+ "")))
+ (or (and mime-decode-unlimited
+ (string-match "\033" filename)
+ (decode-mime-charset-string filename 'iso-2022-jp 'CRLF))
+ (eword-decode-string filename))))
+
+
+(defsubst mime-entity-media-type (entity)
+ "Return primary media-type of ENTITY."
+ (mime-content-type-primary-type (mime-entity-content-type entity)))
+
+(defsubst mime-entity-media-subtype (entity)
+ "Return media-subtype of ENTITY."
+ (mime-content-type-subtype (mime-entity-content-type entity)))
+
+(defsubst mime-entity-parameters (entity)
+ "Return parameters of Content-Type of ENTITY."
+ (mime-content-type-parameters (mime-entity-content-type entity)))
+
+(defsubst mime-entity-type/subtype (entity-info)
+ "Return type/subtype of Content-Type of ENTITY."
+ (mime-type/subtype-string (mime-entity-media-type entity-info)
+ (mime-entity-media-subtype entity-info)))
+
+(defun mime-entity-set-content-type (entity content-type)
+ "Set ENTITY's content-type to CONTENT-TYPE."
+ (mime-entity-set-content-type-internal entity content-type))
+
+(defun mime-entity-set-encoding (entity encoding)
+ "Set ENTITY's content-transfer-encoding to ENCODING."
+ (mime-entity-set-encoding-internal entity encoding))
+
+
+;;; @ unlimited patch
+;;;
+
+;; unlimited patch by simm-emacs@fan.gr.jp (code derives from irchat-pj)
+;; Tue, 01 Feb 2000 01:42:05 +0900
+(defun mime-detect-coding-system-region-unlimited (beg end)
+ "Detect coding system on region."
+ (let (ch esc prev flag)
+ (save-excursion
+ (catch 'detect
+ ;; check ISO-2022-JP / ascii
+ (catch 'quit
+ (goto-char beg)
+ (while (< (point) end)
+ (setq ch (following-char))
+ (and (<= 256 ch)
+ (throw 'detect nil)) ;;'noconv))
+ (and (<= 128 ch)
+ (throw 'quit t))
+ (and (= 27 ch)
+ (setq esc t))
+ (forward-char 1))
+ (throw 'detect (if esc 'iso-2022-jp nil))) ;;'noconv)))
+ ;; check EUC-JP / SHIFT-JIS
+ (if esc (throw 'detect 'iso-2022-jp))
+ (while (< (point) end)
+ (setq ch (following-char))
+ (or (and (= 27 ch) ;; ESC
+ (throw 'detect 'iso-2022-jp))
+ (and (<= 128 ch) (<= ch 141) ;; 0x80 <= ch <= 0x8d
+ (throw 'detect 'shift_jis))
+ (and (<= 144 ch) (<= ch 159) ;; 0x90 <= ch <= 0x9f
+ (throw 'detect 'shift_jis))
+ (and (eq 'shift_jis prev) (<= ch 127) ;; second byte MSB == 0
+ (throw 'detect 'shift_jis))
+ (and (eq 'euc-jp prev)
+ (<= 161 ch) (<= ch 243) ;; second byte of EUC Kana
+ (setq prev nil
+ flag 'euc-jp))
+ (and (eq nil prev)
+ (or (= 164 ch) (= 165 ch)) ;; first byte of EUC kana
+ (setq prev 'euc-jp))
+ (< ch 160) ;; ch <= 0xa0
+ (and (eq 'euc-jp prev)
+ (throw 'detect 'euc-jp))
+ (setq prev (if prev nil 'shift_jis)
+ flag (if (eq 'euc-jp flag) 'euc-jp 'shift_jis)))
+ (forward-char 1))
+ flag))))
+ ;;(or flag 'noconv)))))
+
+;; unlimited patch by simm-emacs@fan.gr.jp
+;; Tue, 01 Feb 2000 01:56:38 +0900
+(defun mime-detect-coding-system-string-unlimited (str)
+ "Detect coding system on string."