1 ;;; mime-lib.el --- MIME library module
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: MIME, multimedia, mail, news
8 ;; This file is part of FLIM (Faithful Library about Internet Message).
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
30 (require 'eword-decode)
32 (defun mime-entity-fetch-field (entity field-name)
33 (or (symbolp field-name)
34 (setq field-name (intern (capitalize (capitalize field-name)))))
35 (let* ((header (mime-entity-original-header entity))
36 (field-body (cdr (assq field-name header))))
40 (set-buffer (mime-entity-buffer entity))
42 (narrow-to-region (mime-entity-header-start entity)
43 (mime-entity-header-end entity))
45 (std11-fetch-field (symbol-name field-name)))
47 (mime-entity-set-original-header
48 entity (put-alist field-name field-body header))
52 (defun mime-entity-read-field (entity field-name)
53 (or (symbolp field-name)
54 (setq field-name (capitalize (capitalize field-name))))
55 (cond ((eq field-name 'Content-Type)
56 (mime-entity-content-type entity)
58 ((eq field-name 'Content-Disposition)
59 (mime-entity-content-disposition entity)
61 ((eq field-name 'Content-Transfer-Encoding)
62 (mime-entity-encoding entity)
65 (let* ((header (mime-entity-parsed-header entity))
66 (field (cdr (assq field-name header))))
68 (let ((field-body (mime-entity-fetch-field entity field-name)))
70 (cond ((memq field-name '(From Resent-From
74 Reply-To Resent-Reply-To))
75 (setq field (std11-parse-addresses
76 (eword-lexical-analyze field-body)))
78 ((eq field-name '(Sender Resent-Sender))
79 (setq field (std11-parse-address
80 (eword-lexical-analyze field-body)))
82 ((memq field-name eword-decode-ignored-field-list)
83 (setq field field-body))
84 ((memq field-name eword-decode-structured-field-list)
85 (setq field (eword-decode-structured-field-body
88 (setq field (eword-decode-unstructured-field-body
91 (mime-entity-set-parsed-header
92 entity (put-alist field-name field header))
101 ;;; mime-lib.el ends here