bd53e6208cd2e6821fe539cc1d983d2389d88ae2
[gnus] / texi / emacs-mime.texi
1 \input texinfo
2
3 @setfilename emacs-mime
4 @settitle Emacs MIME Manual
5 @synindex fn cp
6 @synindex vr cp
7 @synindex pg cp
8 @dircategory Emacs
9 @direntry
10 * Emacs MIME: (emacs-mime).   The MIME de/composition library.
11 @end direntry
12 @iftex
13 @finalout
14 @end iftex
15 @setchapternewpage odd
16
17 @ifnottex
18
19 This file documents the Emacs MIME interface functionality.
20
21 Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
22
23 Permission is granted to copy, distribute and/or modify this document
24 under the terms of the GNU Free Documentation License, Version 1.1 or
25 any later version published by the Free Software Foundation; with no
26 Invariant Sections, with the Front-Cover texts being ``A GNU
27 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
28 license is included in the section entitled ``GNU Free Documentation
29 License'' in the Emacs manual.
30
31 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
32 this GNU Manual, like GNU software.  Copies published by the Free
33 Software Foundation raise funds for GNU development.''
34
35 This document is part of a collection distributed under the GNU Free
36 Documentation License.  If you want to distribute this document
37 separately from the collection, you can do so by adding a copy of the
38 license to the document, as described in section 6 of the license.
39 @end ifnottex
40
41 @tex
42
43 @titlepage
44 @title Emacs MIME Manual
45
46 @author by Lars Magne Ingebrigtsen
47 @page
48
49 @vskip 0pt plus 1filll
50 Copyright @copyright{} 1998, 1999, 2000, 2001, 2002 Free Software
51 Foundation, Inc.
52
53 Permission is granted to copy, distribute and/or modify this document
54 under the terms of the GNU Free Documentation License, Version 1.1 or
55 any later version published by the Free Software Foundation; with the
56 Invariant Sections being none, with the Front-Cover texts being ``A GNU
57 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
58 license is included in the section entitled ``GNU Free Documentation
59 License'' in the Emacs manual.
60
61 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
62 this GNU Manual, like GNU software.  Copies published by the Free
63 Software Foundation raise funds for GNU development.''
64
65 This document is part of a collection distributed under the GNU Free
66 Documentation License.  If you want to distribute this document
67 separately from the collection, you can do so by adding a copy of the
68 license to the document, as described in section 6 of the license.
69 @end titlepage
70 @page
71
72 @end tex
73
74 @node Top
75 @top Emacs MIME
76
77 This manual documents the libraries used to compose and display
78 @sc{mime} messages.
79
80 This manual is directed at users who want to modify the behaviour of
81 the MIME encoding/decoding process or want a more detailed picture of
82 how the Emacs MIME library works, and people who want to write
83 functions and commands that manipulate @sc{mime} elements.
84
85 @sc{mime} is short for @dfn{Multipurpose Internet Mail Extensions}.
86 This standard is documented in a number of RFCs; mainly RFC2045 (Format
87 of Internet Message Bodies), RFC2046 (Media Types), RFC2047 (Message
88 Header Extensions for Non-ASCII Text), RFC2048 (Registration
89 Procedures), RFC2049 (Conformance Criteria and Examples).  It is highly
90 recommended that anyone who intends writing @sc{mime}-compliant software
91 read at least RFC2045 and RFC2047.
92
93 @menu
94 * Interface Functions::   An abstraction over the basic functions.
95 * Basic Functions::       Utility and basic parsing functions.
96 * Decoding and Viewing::  A framework for decoding and viewing.
97 * Composing::             MML; a language for describing @sc{mime} parts.
98 * Standards::             A summary of RFCs and working documents used.
99 * Index::                 Function and variable index.
100 @end menu
101
102
103 @node Interface Functions
104 @chapter Interface Functions
105 @cindex interface functions
106 @cindex mail-parse
107
108 The @code{mail-parse} library is an abstraction over the actual
109 low-level libraries that are described in the next chapter.
110
111 Standards change, and so programs have to change to fit in the new
112 mold.  For instance, RFC2045 describes a syntax for the
113 @code{Content-Type} header that only allows ASCII characters in the
114 parameter list.  RFC2231 expands on RFC2045 syntax to provide a scheme
115 for continuation headers and non-ASCII characters.
116
117 The traditional way to deal with this is just to update the library
118 functions to parse the new syntax.  However, this is sometimes the wrong
119 thing to do.  In some instances it may be vital to be able to understand
120 both the old syntax as well as the new syntax, and if there is only one
121 library, one must choose between the old version of the library and the
122 new version of the library.
123
124 The Emacs @sc{mime} library takes a different tack.  It defines a
125 series of low-level libraries (@file{rfc2047.el}, @file{rfc2231.el}
126 and so on) that parses strictly according to the corresponding
127 standard.  However, normal programs would not use the functions
128 provided by these libraries directly, but instead use the functions
129 provided by the @code{mail-parse} library.  The functions in this
130 library are just aliases to the corresponding functions in the latest
131 low-level libraries.  Using this scheme, programs get a consistent
132 interface they can use, and library developers are free to create
133 write code that handles new standards.
134
135 The following functions are defined by this library:
136
137 @table @code
138 @item mail-header-parse-content-type
139 @findex mail-header-parse-content-type
140 Parse a @code{Content-Type} header and return a list on the following
141 format:
142
143 @lisp
144 ("type/subtype"
145  (attribute1 . value1)
146  (attribute2 . value2)
147  ...)
148 @end lisp
149
150 Here's an example:
151
152 @example
153 (mail-header-parse-content-type
154  "image/gif; name=\"b980912.gif\"")
155 @result{} ("image/gif" (name . "b980912.gif"))
156 @end example
157
158 @item mail-header-parse-content-disposition
159 @findex mail-header-parse-content-disposition
160 Parse a @code{Content-Disposition} header and return a list on the same
161 format as the function above.
162
163 @item mail-content-type-get
164 @findex mail-content-type-get
165 Takes two parameters---a list on the format above, and an attribute.
166 Returns the value of the attribute.
167
168 @example
169 (mail-content-type-get
170  '("image/gif" (name . "b980912.gif")) 'name)
171 @result{} "b980912.gif"
172 @end example
173
174 @item mail-header-encode-parameter
175 @findex mail-header-encode-parameter
176 Takes a parameter string and returns an encoded version of the string.
177 This is used for parameters in headers like @code{Content-Type} and
178 @code{Content-Disposition}.
179
180 @item mail-header-remove-comments
181 @findex mail-header-remove-comments
182 Return a comment-free version of a header.
183
184 @example
185 (mail-header-remove-comments
186  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
187 @result{} "Gnus/5.070027  "
188 @end example
189
190 @item mail-header-remove-whitespace
191 @findex mail-header-remove-whitespace
192 Remove linear white space from a header.  Space inside quoted strings
193 and comments is preserved.
194
195 @example
196 (mail-header-remove-whitespace
197  "image/gif; name=\"Name with spaces\"")
198 @result{} "image/gif;name=\"Name with spaces\""
199 @end example
200
201 @item mail-header-get-comment
202 @findex mail-header-get-comment
203 Return the last comment in a header.
204
205 @example
206 (mail-header-get-comment
207  "Gnus/5.070027 (Pterodactyl Gnus v0.27) (Finnish Landrace)")
208 @result{} "Finnish Landrace"
209 @end example
210
211 @item mail-header-parse-address
212 @findex mail-header-parse-address
213 Parse an address and return a list containing the mailbox and the
214 plaintext name.
215
216 @example
217 (mail-header-parse-address
218  "Hrvoje Niksic <hniksic@@srce.hr>")
219 @result{} ("hniksic@@srce.hr" . "Hrvoje Niksic")
220 @end example
221
222 @item mail-header-parse-addresses
223 @findex mail-header-parse-addresses
224 Parse a string with list of addr