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))
41 (narrow-to-region (mime-entity-header-start entity)
42 (mime-entity-header-end entity))
43 (setq field-body (std11-fetch-field (symbol-name field-name)))
45 (mime-entity-set-original-header
46 entity (put-alist field-name field-body header))
50 (defun mime-entity-read-field (entity field-name)
51 (or (symbolp field-name)
52 (setq field-name (capitalize (capitalize field-name))))
53 (cond ((eq field-name 'Content-Type)
54 (mime-entity-content-type entity)
56 ((eq field-name 'Content-Disposition)
57 (mime-entity-content-disposition entity)
59 ((eq field-name 'Content-Transfer-Encoding)
60 (mime-entity-encoding entity)
63 (let* ((header (mime-entity-parsed-header entity))
64 (field (cdr (assq field-name header))))
66 (let ((field-body (mime-entity-fetch-field entity field-name)))
68 (cond ((memq field-name '(From
72 (setq field (std11-parse-addresses
73 (eword-lexical-analyze field-body)))
75 ((eq field-name 'Sender)
76 (setq field (std11-parse-address
77 (eword-lexical-analyze field-body)))
79 ((memq field-name eword-decode-structured-field-list)
80 (setq field (eword-decode-structured-field-body
83 (setq field (eword-decode-unstructured-field-body
86 (mime-entity-set-parsed-header
87 entity (put-alist field-name field header))
96 ;;; mime-lib.el ends here