mime - Manipulation of MIME body parts
The mime library package provides the commands to create and manipulate MIME body parts.
Creates a MIME part and returns a token representing it.
If the -canonical option is present, then the body is in canonical (raw) form and is found by consulting either the -file, -string, or -parts option.
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 -canonical option is not present, then the MIME part contained in either the -file or the -string option is parsed, dynamically generating subordinates as appropriate.
Destroys the MIME part represented by token. It returns an empty string.
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.
Returns a string or a list of strings containing the properties of a MIME part. If the command is invoked with the name of a specific property, then the corresponding value is returned; instead, if -names is specified, a list of all properties is returned; otherwise, a serialized array of properties and values is returned.
The possible properties are:
The type/subtype describing the content
The "Content-Transfer-Encoding"
A list of "Content-Type" parameters
A list of tokens for the part's subordinates. This property is present only if the MIME part has subordinates.
The approximate size of the content (unencoded)
Returns the header of a MIME part as a dictionary with possibly-redundant keys.
If key is provided, then a list of values of matching names, without regard to case, is returned.
If -names is provided, a list of all keys is returned.
If append is provided, creates a new header named key with the value of value is added. If write is provided, deletes any existing headers whose names match key and then creates a new header named key with the value of value. If delete is provided any existing header having a name that matches key is deleted. Returns a list of strings containing the previous value associated with the key.
The value for -mode is one of:
The key/value is either created or overwritten (the default).
A new value is appended for the key (creating it as necessary).
All values associated with the key are removed (the value parameter is ignored).
Returns a string containing the body of the leaf MIME part represented by token in canonical form.
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.
Copies the MIME represented by token part to the specified channel. The command operates synchronously, and uses fileevent to allow asynchronous operations to proceed independently. It returns an empty string.
Returns the MIME part represented by token as a string. It is similar to ::mime::copymessage, only it returns the data as a return string instead of writing to a channel.
Takes a string containing one or more 822-style address specifications and returns a list of serialized arrays, one element for each address specified in the argument. If the string contains more than one address they will be separated by commas.
Each serialized array contains the properties below. Note that one or more of these properties may be empty.
local@domain
822-style comment
the domain part (rhs)
non-empty on a parse error
this address begins a group
user-friendly rendering
the local part (lhs)
this address belongs to a group
the phrase part
822-style address specification
822-style route specification (obsolete)
Takes a string containing an 822-style date-time specification and returns the specified property as a serialized array.
The list of properties and their ranges are:
0 .. 23
January, February, ..., December
Sunday, Monday, ... Saturday
1 .. 31
0 .. 59
1 .. 12
Jan, Feb, ..., Dec
822-style date-time specification
elapsed seconds between then and now
0 .. 59
0 .. 6 (Sun .. Mon)
Sun, Mon, ..., Sat
1 .. 366
1900 ...
-720 .. 720 (minutes east of GMT)
Maps tcl encodings onto the proper names for their MIME charset type. This is only done for encodings whose charset types were known. The remaining encodings return "" for now.
Maps MIME charset types onto tcl encoding names. Those that are unknown return "".
This problem affects only people which are using Tcl and Mime on a 64-bit system. The currently recommended fix for this problem is to upgrade to Tcl version 8.4. This version has extended 64 bit support and the bug does not appear anymore.
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 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. 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.
Text processing
Copyright © 1999-2000 Marshall T. Rose