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)
33 (autoload 'mime-parse-Content-Type "mime-parse"
34 "Parse STRING as field-body of Content-Type field.")
36 (autoload 'mime-read-Content-Type "mime-parse"
37 "Read field-body of Content-Type field from current-buffer,
38 and return parsed it.")
40 (autoload 'mime-parse-Content-Disposition "mime-parse"
41 "Parse STRING as field-body of Content-Disposition field.")
43 (autoload 'mime-read-Content-Disposition "mime-parse"
44 "Read field-body of Content-Disposition field from current-buffer,
45 and return parsed it.")
47 (autoload 'mime-parse-Content-Transfer-Encoding "mime-parse"
48 "Parse STRING as field-body of Content-Transfer-Encoding field.")
50 (autoload 'mime-read-Content-Transfer-Encoding "mime-parse"
51 "Read field-body of Content-Transfer-Encoding field from
52 current-buffer, and return it.")
54 (autoload 'mime-parse-message "mime-parse"
55 "Parse current-buffer as a MIME message.")
57 (autoload 'mime-parse-buffer "mime-parse"
58 "Parse BUFFER as a MIME message.")
61 (defun mime-entity-fetch-field (entity field-name)
62 (or (symbolp field-name)
63 (setq field-name (intern (capitalize (capitalize field-name)))))
64 (let* ((header (mime-entity-original-header entity))
65 (field-body (cdr (assq field-name header))))
69 (set-buffer (mime-entity-buffer entity))
71 (narrow-to-region (mime-entity-header-start entity)
72 (mime-entity-header-end entity))
74 (std11-fetch-field (symbol-name field-name)))
76 (mime-entity-set-original-header
77 entity (put-alist field-name field-body header))
81 (defun mime-entity-read-field (entity field-name)
82 (or (symbolp field-name)
83 (setq field-name (capitalize (capitalize field-name))))
84 (cond ((eq field-name 'Content-Type)
85 (mime-entity-content-type entity)
87 ((eq field-name 'Content-Disposition)
88 (mime-entity-content-disposition entity)
90 ((eq field-name 'Content-Transfer-Encoding)
91 (mime-entity-encoding entity)
94 (let* ((header (mime-entity-parsed-header entity))
95 (field (cdr (assq field-name header))))
97 (let ((field-body (mime-entity-fetch-field entity field-name)))
99 (cond ((memq field-name '(From Resent-From
103 Reply-To Resent-Reply-To))
104 (setq field (std11-parse-addresses
105 (eword-lexical-analyze field-body)))
107 ((eq field-name '(Sender Resent-Sender))
108 (setq field (std11-parse-address
109 (eword-lexical-analyze field-body)))
111 ((memq field-name eword-decode-ignored-field-list)
112 (setq field field-body))
113 ((memq field-name eword-decode-structured-field-list)
114 (setq field (eword-decode-structured-field-body
117 (setq field (eword-decode-unstructured-field-body
120 (mime-entity-set-parsed-header
121 entity (put-alist field-name field header))
130 ;;; mime-lib.el ends here