annotate Doc/lib/libmailcap.tex @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents c90f0036109d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8918
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
1 \section{\module{mailcap} ---
acfffe14628e New section header style.
Fred Drake <fdrake@acm.org>
parents: 8716
diff changeset
2 Mailcap file handling.}
8716
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
3 \declaremodule{standard}{mailcap}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
4
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
5 \modulesynopsis{Mailcap file handling.}
760dcf197048 Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents: 7877
diff changeset
6
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 Mailcap files are used to configure how MIME-aware applications such
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 as mail readers and Web browsers react to files with different MIME
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 types. (The name ``mailcap'' is derived from the phrase ``mail
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 capability''.) For example, a mailcap file might contain a line like
6953
dc0739379714 Changed all \verb\...\ markup to either \code{...} or \samp{...}.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
12 \samp{video/mpeg; xmpeg \%s}. Then, if the user encounters an email
7785
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
13 message or Web document with the MIME type \mimetype{video/mpeg},
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
14 \samp{\%s} will be replaced by a filename (usually one belonging to a
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
15 temporary file) and the \program{xmpeg} program can be automatically
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
16 started to view the file.
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
7219
640b97d105df Use the new RFC macros wherever RFCs are referenced by number. No other
Fred Drake <fdrake@acm.org>
parents: 7089
diff changeset
18 The mailcap format is documented in \rfc{1524}, ``A User Agent
7229
bc28a0ea6640 Removed all references to the \rfcindex{} macro; now only \rfc{} is used.
Fred Drake <fdrake@acm.org>
parents: 7219
diff changeset
19 Configuration Mechanism For Multimedia Mail Format Information,'' but
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 is not an Internet standard. However, mailcap files are supported on
7089
29b1686875da Consistency: "unix" ==> "\UNIX{}"
Fred Drake <fdrake@acm.org>
parents: 6953
diff changeset
21 most \UNIX{} systems.
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
7785
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
23 \begin{funcdesc}{findmatch}{caps, MIMEtype%
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
24 \optional{, key\optional{,
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
25 filename\optional{, plist}}}}
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 Return a 2-tuple; the first element is a string containing the command
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 line to be executed
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
28 (which can be passed to \function{os.system()}), and the second element is
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 the mailcap entry for a given MIME type. If no matching MIME
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 type can be found, \code{(None, None)} is returned.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
31
7219
640b97d105df Use the new RFC macros wherever RFCs are referenced by number. No other
Fred Drake <fdrake@acm.org>
parents: 7089
diff changeset
32 \var{key} is the name of the field desired, which represents the type
640b97d105df Use the new RFC macros wherever RFCs are referenced by number. No other
Fred Drake <fdrake@acm.org>
parents: 7089
diff changeset
33 of activity to be performed; the default value is 'view', since in the
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 most common case you simply want to view the body of the MIME-typed
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
35 data. Other possible values might be 'compose' and 'edit', if you
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 wanted to create a new body of the given MIME type or alter the
7219
640b97d105df Use the new RFC macros wherever RFCs are referenced by number. No other
Fred Drake <fdrake@acm.org>
parents: 7089
diff changeset
37 existing body data. See \rfc{1524} for a complete list of these
640b97d105df Use the new RFC macros wherever RFCs are referenced by number. No other
Fred Drake <fdrake@acm.org>
parents: 7089
diff changeset
38 fields.
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
39
7785
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
40 \var{filename} is the filename to be substituted for \samp{\%s} in the
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
41 command line; the default value is
7785
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
42 \code{'/dev/null'} which is almost certainly not what you want, so
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 usually you'll override it by specifying a filename.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 \var{plist} can be a list containing named parameters; the default
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
46 value is simply an empty list. Each entry in the list must be a
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
47 string containing the parameter name, an equals sign (\character{=}),
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
48 and the parameter's value. Mailcap entries can contain
6953
dc0739379714 Changed all \verb\...\ markup to either \code{...} or \samp{...}.
Fred Drake <fdrake@acm.org>
parents: 5818
diff changeset
49 named parameters like \code{\%\{foo\}}, which will be replaced by the
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 value of the parameter named 'foo'. For example, if the command line
7785
05692c661434 Some nits.
Fred Drake <fdrake@acm.org>
parents: 7712
diff changeset
51 \samp{showpartial \%\{id\}\ \%\{number\}\ \%\{total\}}
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 was in a mailcap file, and \var{plist} was set to \code{['id=1',
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 'number=2', 'total=3']}, the resulting command line would be
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
54 \code{'showpartial 1 2 3'}.
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
55
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
56 In a mailcap file, the ``test'' field can optionally be specified to
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
57 test some external condition (such as the machine architecture, or the
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 window system in use) to determine whether or not the mailcap line
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
59 applies. \function{findmatch()} will automatically check such
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
60 conditions and skip the entry if the check fails.
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 \end{funcdesc}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
62
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 \begin{funcdesc}{getcaps}{}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 Returns a dictionary mapping MIME types to a list of mailcap file
19055
c90f0036109d Clean up some of the markup here -- be more consistent in the use of
Fred Drake <fdrake@acm.org>
parents: 8918
diff changeset
65 entries. This dictionary must be passed to the \function{findmatch()}
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 function. An entry is stored as a list of dictionaries, but it
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
67 shouldn't be necessary to know the details of this representation.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
68
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 The information is derived from all of the mailcap files found on the
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
70 system. Settings in the user's mailcap file \file{\$HOME/.mailcap}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 will override settings in the system mailcap files
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 \file{/etc/mailcap}, \file{/usr/etc/mailcap}, and
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 \file{/usr/local/etc/mailcap}.
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 \end{funcdesc}
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
75
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
76 An example usage:
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7229
diff changeset
77 \begin{verbatim}
5217
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 >>> import mailcap
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
79 >>> d=mailcap.getcaps()
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 >>> mailcap.findmatch(d, 'video/mpeg', filename='/tmp/tmp1223')
3ab7d58c2963 Added docs for mailcap
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 ('xmpeg /tmp/tmp1223', {'view': 'xmpeg %s'})
7277
bf4e790bd61a Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents: 7229
diff changeset
82 \end{verbatim}