1/*  Part of SWI-Prolog
    2
    3    Author:        Jan Wielemaker
    4    E-mail:        J.Wielemaker@vu.nl
    5    WWW:           http://www.swi-prolog.org
    6    Copyright (c)  2001-2012, University of Amsterdam
    7    All rights reserved.
    8
    9    Redistribution and use in source and binary forms, with or without
   10    modification, are permitted provided that the following conditions
   11    are met:
   12
   13    1. Redistributions of source code must retain the above copyright
   14       notice, this list of conditions and the following disclaimer.
   15
   16    2. Redistributions in binary form must reproduce the above copyright
   17       notice, this list of conditions and the following disclaimer in
   18       the documentation and/or other materials provided with the
   19       distribution.
   20
   21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   24    FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   25    COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   26    INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   27    BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   28    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   29    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   30    LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   31    ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   32    POSSIBILITY OF SUCH DAMAGE.
   33*/
   34
   35:- module(mime,
   36          [ mime_parse/2,               % +Data, -Mime
   37            mime_default_charset/2      % -Old, +New
   38          ]).   39:- use_module(library(shlib)).   40
   41:- use_foreign_library(foreign(mime), install_mime).

Parse MIME documents

This module defines an interface to the rfc2045 (MIME) parsing library by Double Precision, Inc, part of the maildrop system. This library is distributed under the GPL and therefore all code using this library should comply to the GPL. */

 mime_parse(+Data, -Parsed) is det
True when Parsed is a parsed representation of the MIME message in Data. Data is one of

Parsed is a structure of this form:

Where Data is the (decoded) field data returned as an atom. If a part is of type text/..., the charset is interpreted as follows: if charset contains UTF-8 or an alias thereof, the text is interpreted as UTF-8. If it the charset can be interpreted as ISO-8859-1 or US-ASCII, no conversion is applied. Otherwise, default locale specific conversion is applied. See also mime_default_charset/2.

Attributes is a property-list and SubMimeList is a list of mime/3 terms reflecting the sub-parts. Attributes contains the following members:

id(Atom)
Identifier of the message-part.
description(Atom)
Descriptive text for the \arg{Data}.
language(Atom)
Language in which the text-data is written.
md5(Atom)
type(Atom)
Denotes the Content-Type, how the \arg{Data} should be interpreted.
character_set(Atom)
The character set used for text data. See above.
transfer_encoding(Atom)
How the \arg{Data} was encoded. This is not very interesting as the library decodes the content of the message.
disposition(Atom)
Where the data comes from. The current library only deals with `inline' data.
filename(Atom)
Name of the file the data should be stored in.
name(Atom)
Name of the part.
 mime_default_charset(-Old, +New) is det
True when Old reflects the old and new the new default character set of the library. The system default is us-ascii. This value is returned into the attribute character_set (see mime_parse/2) if the message does not explicitly specifythe character set. It is used for translating the message content.
bug
- This setting is global and shared between threads.