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.")
64 (defun mime-entity-fetch-field (entity field-name)
65 (or (symbolp field-name)
66 (setq field-name (intern (capitalize (capitalize field-name)))))
67 (let* ((header (mime-entity-original-header entity))
68 (field-body (cdr (assq field-name header))))
72 (set-buffer (mime-entity-buffer entity))
74 (narrow-to-region (mime-entity-header-start entity)
75 (mime-entity-header-end entity))
77 (std11-fetch-field (symbol-name field-name)))
79 (mime-entity-set-original-header
80 entity (put-alist field-name field-body header))
84 (defun mime-entity-read-field (entity field-name)
85 (or (symbolp field-name)
86 (setq field-name (capitalize (capitalize field-name))))
87 (cond ((eq field-name 'Content-Type)
88 (mime-entity-content-type entity)
90 ((eq field-name 'Content-Disposition)
91 (mime-entity-content-disposition entity)
93 ((eq field-name 'Content-Transfer-Encoding)
94 (mime-entity-encoding entity)
97 (let* ((header (mime-entity-parsed-header entity))
98 (field (cdr (assq field-name header))))
100 (let ((field-body (mime-entity-fetch-field entity field-name)))
102 (cond ((memq field-name '(From Resent-From
106 Reply-To Resent-Reply-To))
107 (setq field (std11-parse-addresses
108 (eword-lexical-analyze field-body)))
110 ((eq field-name '(Sender Resent-Sender))
111 (setq field (std11-parse-address
112 (eword-lexical-analyze field-body)))
114 ((memq field-name eword-decode-ignored-field-list)
115 (setq field field-body))
116 ((memq field-name eword-decode-structured-field-list)
117 (setq field (eword-decode-structured-field-body
120 (setq field (eword-decode-unstructured-field-body
123 (mime-entity-set-parsed-header
124 entity (put-alist field-name field header))
127 (defsubst mime-root-entity-p (entity)
128 "Return t if ENTITY is root-entity (message)."
129 (null (mime-entity-node-id entity)))
137 ;;; mime-lib.el ends here