mime(3tcl) | Mime | mime(3tcl) |
mime - Manipulation of MIME body parts
package require Tcl 8.5
package require mime ?1.6.2?
::mime::initialize ?-canonical type/subtype ?-param {key value}...? ?-encoding value? ?-header {key value}...?? (-file name | -string value | -parts {token1 ... tokenN})
::mime::finalize token ?-subordinates all | dynamic | none?
::mime::getproperty token ?property | -names?
::mime::getheader token ?key | -names?
::mime::setheader token key value ?-mode write | append | delete?
::mime::getbody token ?-decode? ?-command callback ?-blocksize octets??
::mime::copymessage token channel
::mime::buildmessage token
::mime::parseaddress string
::mime::parsedatetime (string | -now) property
::mime::mapencoding encoding_name
::mime::reversemapencoding charset_type
The mime library package provides the commands to create and manipulate MIME body parts.
In addition, both the -param and -header options may occur zero or more times to specify Content-Type parameters (e.g., charset) and header keyword/values (e.g., Content-Disposition), respectively.
Also, -encoding, if present, specifies the Content-Transfer-Encoding when copying the body.
If the -subordinates option is present, it specifies which subordinates should also be destroyed. The default value is dynamic, destroying all subordinates which were created by ::mime::initialize together with the containing body part.
The possible properties are:
A header consists of zero or more key/value pairs. Each value is a list containing one or more strings.
If this command is invoked with the name of a specific key, then a list containing the corresponding value(s) is returned; instead, if -names is specified, a list of all keys is returned; otherwise, a serialized array of keys and values is returned. Note that when a key is specified (e.g., "Subject"), the list returned usually contains exactly one string; however, some keys (e.g., "Received") often occur more than once in the header, accordingly the list returned usually contains more than one string.
The value for -mode is one of:
If the -command option is present, then it is repeatedly invoked with a fragment of the body as this:
uplevel #0 $callback [list "data" $fragment]
(The -blocksize option, if present, specifies the maximum size of each fragment passed to the callback.)
When the end of the body is reached, the callback is invoked as:
uplevel #0 $callback "end"
Alternatively, if an error occurs, the callback is invoked as:
uplevel #0 $callback [list "error" reason]
Regardless, the return value of the final invocation of the callback is propagated upwards by ::mime::getbody.
If the -command option is absent, then the return value of ::mime::getbody is a string containing the MIME part's entire body.
If the option -decode is absent the return value computed above is returned as is. This means that it will be in the charset specified for the token and not the usual utf-8. If the option -decode is present however the command will use the charset information associated with the token to convert the string from its encoding into utf-8 before returning it.
Each serialized array contains the properties below. Note that one or more of these properties may be empty.
The list of properties and their ranges are:
The problem could have been generally solved by requiring the use of Tcl 8.4 for this package. We decided against this solution as it would force a large number of unaffected users to upgrade their Tcl interpreter for no reason.
See Ticket 447037 [/tktview?name=447037] for additional information.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category mime of the Tcllib Trackers [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
ftp, http, pop3, smtp
email, internet, mail, mime, net, rfc 2045, rfc 2046, rfc 2049, rfc 821, rfc 822, smtp
Text processing
Copyright (c) 1999-2000 Marshall T. Rose
1.6.2 | tcllib |