N/A
<MIMEFILTERS>
filter-specification
...
</MIMEFILTERS>
N/A
The resource MIMEFILTERS
is used to hook in user
specifed filters into MHonArc.
The MIMEFILTERS resource can only be set via the
MIMEFILTERS
element.
The syntax for each line of
the the MIMEFILTERS
element is as follows:
content-type:
routine-name:
file-of-routine
The definition of each colon-separated value is as follows:
The MIME content-type the filter processes. An explicit content-type (base/subtype) or a base content-type (base/*) can be specified.
The actual routine name of the filter. The name
should be fully qualified by the package it is defined in
(e.g. "mypackage'filter
").
NOTE | Package qualification must use Perl 4 syntax. The Perl 5
' |
The name of the file that defines routine-name. If the file is not a full pathname, MHonArc finds the file by looking in the standard include paths of Perl, and the paths specified by the PERLINC resource.
Any whitespace is stripped out before processing.
If you want to write your own filter for use in MHonArc, you need to know the Perl programming language. The following information assumes you know Perl.
NOTE | The filter model follows Perl 4 syntax conventions and constructs. This is because of historical reasons. Note, the implementation of the filter can use Perl 5 syntax and features, where applicable, if running MHonArc under Perl 5. |
NOTE | The default filters provided by MHonArc are described in the Default Settings section. |
MHonArc interfaces with MIME filters by calling a routine with a specific set of arguments. The prototype of the interface routine is as follows:
sub filter { local($head, *fields, $data, $decoded, $argstring) = @_; # Filter code here # The last statement should be the return value, unless an # explicit return is done. See the following for the format of the # return value. }
$head |
This is the header text of the message (or body part if called in a multipart message). |
||
*fields |
A pointer (typeglob) to an associative array that has broken down
If a field occurs more than once in a header, MHonArc
separates the field values in the associative array by a
`
|
||
$data |
This is a copy of the message (or body part if called in a mulitpart message) body. |
||
$decoded |
This flag is set to 1 if MHonArc decoded the message
and MHonArc has decoded the data for you if it was encoded in 7-Bit, 8-Bit, Binary, Quoted-Printable, Base64, Uuencode (x-uuencode, uuencode, x-uue, uue). |
||
$argstring |
This is an optional argument string that may be used to modify the behavior of the filter. The format of this string is determined by the filter itself. The value of the string is set by the MIMEARGS resource. |
The return value is treated as an array. The first item in the array is a string representing the HTML markup to insert in the HTMLized message. An empty string may be returned to tell MHonArc that the routine was unable to filter data.
Any other array items are treated as names of any files that were generated by the filter. MHonArc needs to keep track if any extra files that a filter may generate in order for MHonArc to delete those files if the message gets removed from the archive.
NOTE | If the filter creates a subdirectory with files, the filter only needs to return the subdirectory in the return list. If the message gets removed, MHonArc will delete the entire directory. |
The following recommendations/tips are given to help you write filters:
Qualify your filter in its own package. This eliminates possible variable/routine conflicts with MHonArc.
If the filter creates derived files (like the image filters),
you may use the variable $'OUTDIR
to determine the
location of the mail archive.
NOTE | Do not include
|
Look at the default filters contained in the distribution of MHonArc. You can use these as templates for writing your own.
Make sure your Perl source file ends with a true statement
(like "1;
"). MHonArc just performs a
require
on the file, and if the file does not return
true, Perl will abort execution.
If a MIME filter requires the utilization of a C program, or other non-Perl executable, a Perl wrapper must be written for the program in-order to interface with MHonArc.
<MIMEFilters> application/*:m2h_external'filter:mhexternal.pl application/x-patch:m2h_text_plain'filter:mhtxtplain.pl audio/*:m2h_external'filter:mhexternal.pl model/*:m2h_external'filter:mhexternal.pl image/*:m2h_external'filter:mhexternal.pl message/partial:m2h_text_plain'filter:mhtxtplain.pl text/*:m2h_text_plain'filter:mhtxtplain.pl text/enriched:m2h_text_enriched'filter:mhtxtenrich.pl text/html:m2h_text_html'filter:mhtxthtml.pl text/plain:m2h_text_plain'filter:mhtxtplain.pl text/richtext:m2h_text_enriched'filter:mhtxtenrich.pl text/setext:m2h_text_setext'filter:mhtxtsetext.pl text/tab-separated-values:m2h_text_plain'filter:mhtxtplain.pl text/x-html:m2h_text_html'filter:mhtxthtml.pl text/x-setext:m2h_text_setext'filter:mhtxtsetext.pl video/*:m2h_external'filter:mhexternal.pl </MIMEFilters>
The following describes the behavior of each filter.
The filter extracts the data into a separate file and puts a hyperlink to the file into the HTMLized message.
By default, the filter ignores any filename specification given in the message when writing the data to disk. A unique filename with an extenstion based upon sub-type is generated.
m2h_external'filter can take the following arguments:
iconurl="url" | Use "url" as the url for the icon to use if the useicon option is set. This option will override any setting defined by the ICONS resource. The double quotes are required. |
inline | Inline image data by default if content-disposition not defined. |
ext=ext | Use ext as the filename extension. The filter already has a large list of extensions for various content-types. Use this argument if you process a content-type not recognized by the filter. |
type="description" | Use "description" as type description of the data. The double quotes are required. The filter already has a large list of descriptions for various content-types. Use this argument if you process a content-type not recognized by the filter. |
subdir | Place derived file in a subdirectory of the archive. The subdirectory will be called "msgMSGNUM.dir". This option may be useful if usename is specified to avoid security and name conflict problems. |
useicon | Include a content-type icon with the hyperlink to the derived file. The icon used is the value of the iconurl option or the icon defined by the ICONS resource. |
usename | Use (file)name attribute for determining name of derived file. Use this option with caution since it can lead to filename conflicts and security problems (however, see the subdir option). |
All arguments should be separated by at least one space.
The following table shows the default list of content-types, with descriptions, m2h_external'filter recognizes:
Content-type | Description |
---|---|
application/astound | Astound presentation |
application/fastman | fastman file |
application/fractals | Fractal Image Format |
application/iges | IGES file |
application/mac-binhex40 | Mac BinHex archive |
application/mbedlet | mbedlet file |
application/msword | MS-Word document |
application/octet-stream | Binary data |
application/oda | ODA file |
application/pdf | PDF document |
application/pgp | PGP message |
application/pgp-signature | PGP signature |
application/postscript | PostScript document |
application/rtf | RTF file |
application/sgml | SGML document |
application/studiom | Studio M file |
application/timbuktu | timbuktu file |
application/vnd.ms-excel | MS-Excel spreadsheet |
application/vnd.ms-powerpoint | MS-Powerpoint presentation |
application/vnd.ms-project | MS-Project file |
application/winhlp | WinHelp document |
application/wordperfect5.1 | WordPerfect 5.1 document |
application/x-NET-Install | Net Install file |
application/x-asap | asap file |
application/x-bcpio | BCPIO file |
application/x-compress | Unix compressed data |
application/x-cpio | CPIO file |
application/x-csh | C-Shell script |
application/x-dot | dot file |
application/x-dvi | TeX dvi file |
application/x-earthtime | Earthtime file |
application/x-envoy | Envoy file |
application/x-excel | MS-Excel spreadsheet |
application/x-gtar | GNU Unix tar archive |
application/x-gzip | GNU Zip compressed data |
application/x-hdf | HDF file |
application/x-javascript | JavaScript source |
application/x-ksh | Korn Shell script |
application/x-latex | LaTeX document |
application/x-maker | FrameMaker document |
application/x-mif | Frame MIF document |
application/x-mocha | mocha file |
application/x-msaccess | MS-Access database |
application/x-mscardfile | MS-CardFile |
application/x-msclip | MS-Clip file |
application/x-msmediaview | MS-Media View file |
application/x-msmetafile | MS-Metafile |
application/x-msmoney | MS-Money file |
application/x-mspublisher | MS-Publisher document |
application/x-msschedule | MS-Schedule file |
application/x-msterminal | MS-Terminal |
application/x-mswrite | MS-Write document |
application/x-netcdf | Cdf file |
application/x-ns-proxy-autoconfig | Netscape Proxy Auto Config |
application/x-patch | Source code patch |
application/x-perl | Perl program |
application/x-pointplus | pointplus file |
application/x-salsa | salsa file |
application/x-script | A script file |
application/x-sh | Bourne shell script |
application/x-shar | Unix shell archive |
application/x-sprite | sprite file |
application/x-stuffit | Macintosh archive |
application/x-sv4cpio | SV4Cpio file |
application/x-sv4crc | SV4Crc file |
application/x-tar | Unix tar archive |
application/x-tcl | Tcl script |
application/x-tex | TeX document |
application/x-texinfo | TeXInfo document |
application/x-timbuktu | timbuktu file |
application/x-tkined | tkined file |
application/x-troff | Troff document |
application/x-troff-man | Unix manual page |
application/x-troff-me | Troff ME-macros document |
application/x-troff-ms | Troff MS-macros document |
application/x-ustar | UStar file |
application/x-wais-source | WAIS Source |
application/x-zip-compressed | Zip compressed data |
application/zip | Zip archive |
audio/basic | Basic audio |
audio/echospeech | Echospeech audio |
audio/midi | MIDI audio |
audio/x-aiff | AIF audio |
audio/x-epac | epac audio |
audio/x-midi | MIDI audio |
audio/x-pac | pac audio |
audio/x-pn-realaudio | PN Realaudio |
audio/x-wav | Wave audio |
image/bmp | Windows bitmap |
image/cgm | Computer Graphics Metafile |
image/fif | Fractal Image Format image |
image/gif | GIF image |
image/ief | IEF image |
image/ifs | IFS image |
image/jpeg | JPEG image |
image/png | PNG image |
image/tiff | TIFF image |
image/vnd | VND image |
image/wavelet | Wavelet image |
image/x-bmp | Windows bitmap |
image/x-cmu-raster | CMU raster |
image/x-pbm | Portable bitmap |
image/x-pcx | PCX image |
image/x-pgm | Portable graymap |
image/x-pict | Mac PICT image |
image/x-pnm | Portable anymap |
image/x-portable-anymap | Portable anymap |
image/x-portable-bitmap | Portable bitmap |
image/x-portable-graymap | Portable graymap |
image/x-portable-pixmap | Portable pixmap |
image/x-ppm | Portable pixmap |
image/x-rgb | RGB image |
image/x-xbitmap | X bitmap |
image/x-xbm | X bitmap |
image/x-xpixmap | X pixmap |
image/x-xpm | X pixmap |
image/x-xwd | X window dump |
image/x-xwindowdump | X window dump |
model/iges | IGES model |
model/mesh | Mesh model |
model/vrml | VRML model |
text/enriched | Enriched document |
text/html | HTML document |
text/plain | Text document |
text/richtext | Richtext document |
text/setext | Setext document |
text/sgml | SGML document |
text/x-html | HTML document |
text/x-setext | Setext document |
text/x-speech | Speech document |
video/isivideo | isi video |
video/mpeg | MPEG movie |
video/msvideo | MS Video |
video/quicktime | QuickTime movie |
video/vivo | vivo video |
video/wavelet | Wavelet video |
video/x-msvideo | MS video |
video/x-sgi-movie | SGI movie |
This filter is designed to process text/enriched, or text/richtext, data. The following table summarizes the translation of text/enriched commands to HTML tags:
Text/Enriched Command | HTML Translation |
---|---|
<Bold> | <B> |
<Italic> | <I> |
<Underline> | <U> |
<Fixed> | <TT> |
<Smaller> | <SMALL> |
<Bigger> | <BIG> |
<FontFamily><Param>family</Param> | <FONT face="family"> |
<Color><Param>color</Param> | <FONT color="color"> |
<Center> | <P align="center"> |
<FlushLeft> | <P align="left"> |
<FlushRight> | <P align="right"> |
<FlushBoth> | <P align="both"> (not supported in HTML) |
<ParaIndent> | <BLOCKQUOTE> |
<Excerpt> | <BLOCKQUOTE> |
<Lang> | Stripped |
If the text/enriched contains non-ASCII character, the filter will convert the characters to the appropriate entity references.
NOTE | Only the ISO-8859-[1-10] character sets are recognized. |
This filter is designed to process text/html or text/x-html data. The filter modifies the HTML so it can be included validly into the message page. Any head data will be stripped out, but the title will be extracted and prepended to the body data.
This filter is designed to process text/plain messages and messages with no MIME information. The filter is also used to process text messages of an unknown subtype.
The default behavior of the filter is wrap the data in the HTML PRE element and escape special characters. It will also convert text that looks like a URL into a hyperlink. If the data contains non-ASCII character, the filter will convert the characters to the appropriate entity reference.
NOTE | Only the ISO-8859-[1-10] and ISO-2022-JP character sets are recognized. For ISO-2022-JP data, a Web client with ISO-2022-JP is required to read the data. |
m2h_text_plain'filter can take the following arguments:
asis=set1:... | Colon separated lists of charsets to leave as-is. Only HTML special characters will be converted into entities. |
keepspace | Preserve all spaces if the nonfixed option is specified. All spaces and tabs will be translated to the equivalent number of entity references. |
maxwidth=# | Force the maximum width of lines to be # characters in length. Any lines longer than # characters will be wrapped. |
nonfixed | Do not wrap message text in the HTML PRE element. This will cause text to be rendered in the default font (which is normally proportionally spaced). Each line of the message will have a <BR> appended in order to preserve the line representation of the message. |
nourl | Do not hyperlink URLs. |
quote | Italicize quoted message text. |
All arguments should be separated by at least one space.
This filter converts text/setext and text/x-setext messages to HTML.
N/A
None.
1.0