1 ;;; rfc2231.el --- Functions for decoding rfc2231 headers
2 ;; Copyright (C) 1998,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to the
19 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
28 (defun rfc2231-get-value (ct attribute)
29 "Return the value of ATTRIBUTE from CT."
30 (cdr (assq attribute (cdr ct))))
32 (defun rfc2231-parse-string (string)
33 "Parse STRING and return a list.
34 The list will be on the form
35 `(name (attribute . value) (attribute . value)...)"
37 (let ((ttoken (ietf-drums-token-to-list ietf-drums-text-token))
38 (stoken (ietf-drums-token-to-list ietf-drums-tspecials))
39 (ntoken (ietf-drums-token-to-list "0-9"))
41 display-name mailbox c display-string parameters
42 attribute value type subtype number encoded
44 (ietf-drums-init (mail-header-remove-whitespace
45 (mail-header-remove-comments string)))
46 (let ((table (copy-syntax-table ietf-drums-syntax-table)))
47 (modify-syntax-entry ?\' "w" table)
48 ;; The following isn't valid, but one should be liberal
49 ;; in what one receives.
50 (modify-syntax-entry ?\: "w" table)
51 (set-syntax-table table))
53 (when (and (memq c ttoken)
54 (not (memq c stoken)))
55 (setq type (downcase (buffer-substring
56 (point) (progn (forward-sexp 1) (point)))))
61 (error "Invalid header: %s" string))
63 ;; If c in nil, then this is an invalid header, but
64 ;; since elm generates invalid headers on this form,
66 (when (setq c (char-after))
67 (if (and (memq c ttoken)
68 (not (memq c stoken)))
73 (point) (progn (forward-sexp 1) (point))))))
74 (error "Invalid header: %s" string))