Common Lisp Package: CL-MIME

A package for constructing MIME objects for printing and parsing MIME formatted strings or streams.

README:

FUNCTION

Public

GET-CONTENT-DISPOSITION-PARAMETER (MIME-OBJ PARAMETER-NAME)

Provided a parameter name in the form of a keyword, will get the corresponding value from the parameter list of the Content-Disposition header

GET-CONTENT-TYPE-PARAMETER (MIME-OBJ PARAMETER-NAME)

Provided a parameter name in the form of a keyword, will get the corresponding value from the parameter list of the Content-Type header

GET-MIME-HEADERS (MIME-OBJ)

Retrieves all known headers in mime-obj

HEADER-COMMENTS (HEADER)

Returns all comments from the keyword/value header pair in HEADER

HEADER-PARMS (HEADER)

Takes a header cons and returns all parameters contained within

HEADER-VALUE (HEADER)

Takes a header cons and returns the value component

LOOKUP-MIME (PATHNAME &OPTIONAL MIME-TYPES-FILE)

Takes a PATHNAME argument and uses MIME-TYPES-FILE (or the system default) to determine the mime type of PATHNAME. Returns two values: the content type and the the content subtype

MAKE-CONTENT-ID

Make a Content-ID header value

PARSE-HEADERS (STREAM)

Parses headers from a stream and converts them into keyword/value pairs

Undocumented

DECODE-CONTENT (MIME)

ENCODE-CONTENT (MIME)

Private

ADD-TO-PRINT-HEADERS (KEY ALIST HEADERS-OUT)

Adds a requested header from the provided alist to a printable headers string

CREATE-HEADER (HEADER-STRING)

Takes a header string and returns a keyword/value header pair

ENSURE-KEYWORD (NAME)

Returns keyword for a name

EXTRACT-HEADER-COMMENTS (HEADER-VALUE-STRING &OPTIONAL COMMENT-LIST)

Takes a header string and optional list of already extracted comments and returns all comments contained within that string

EXTRACT-PARMS (PARM-STRING &OPTIONAL PARMS)

Takes a string of parameters and returns a list of keyword/value parameter pairs

MAKE-BOUNDARY

This just makes a boundary out of random junk

READ-UNTIL-BOUNDARY (STREAM BOUNDARY)

Reads a MIME body from STREAM until it reaches a boundary defined by BOUNDARY

Undocumented

READ-LINE/STRIP-CR (&REST ARGS)

MACRO

Private

READ-LINES ((LINE-VAR STREAM) (EXIT-CLAUSE &BODY EXIT-BODY) &BODY BODY)

Reads lines into LINE-VAR from STREAM until either EOF is reached or EXIT-CLAUSE is true where upon EXIT-BODY is executed. Executes BODY for every line in the file

READ-STREAM-TO-STRING (STREAM LINE-VAR &OPTIONAL EXIT-CLAUSE)

Reads STREAM until EOF and returns a string containing the contents

Undocumented

AIF (TEST THEN &OPTIONAL ELSE)

GENERIC-FUNCTION

Public

GET-HEADER (MIME-OBJ HEADER)

Returns a cons of header name (in keyword format) and value

PARSE-BODY (BODY MIME-TYPE &OPTIONAL BOUNDARY)

Parses a mime body within the context of the mime type expected. Assumes the stream's position is already at the body. If it's not, you should call parse headers first or read through to the first null line.

PARSE-MIME (MIME &OPTIONAL HEADERS)

Parse a string or stream containing a MIME message and return a mine object representing it or nil if the message is not MIME compatible

Private

GET-EPILOGUE (BODY)

Grab the prologue from a Multipart MIME message

GET-PROLOGUE (BODY BOUNDARY)

Grab the prologue from a Multipart MIME message

SLOT-ACCESSOR

Public

CONTENT-TRANSFER-ENCODING (OBJECT)

Encoding to use when printing the MIME content. May be :7BIT :BASE64 or :QUOTED-PRINTABLE

SETFCONTENT-TRANSFER-ENCODING (NEW-VALUE OBJECT)

Encoding to use when printing the MIME content. May be :7BIT :BASE64 or :QUOTED-PRINTABLE

Undocumented

BOUNDARY (OBJECT)

SETFBOUNDARY (NEW-VALUE OBJECT)

CHARSET (OBJECT)

SETFCHARSET (NEW-VALUE OBJECT)

CONTENT (OBJECT)

SETFCONTENT (NEW-VALUE OBJECT)

CONTENT-DESCRIPTION (OBJECT)

SETFCONTENT-DESCRIPTION (NEW-VALUE OBJECT)

CONTENT-DISPOSITION (OBJECT)

SETFCONTENT-DISPOSITION (NEW-VALUE OBJECT)

CONTENT-DISPOSITION-PARAMETERS (OBJECT)

SETFCONTENT-DISPOSITION-PARAMETERS (NEW-VALUE OBJECT)

CONTENT-ID (OBJECT)

SETFCONTENT-ID (NEW-VALUE OBJECT)

CONTENT-SUBTYPE (OBJECT)

CONTENT-TYPE (OBJECT)

CONTENT-TYPE-PARAMETERS (OBJECT)

SETFCONTENT-TYPE-PARAMETERS (NEW-VALUE OBJECT)

EPILOGUE (OBJECT)

SETFEPILOGUE (NEW-VALUE OBJECT)

MIME-VERSION (OBJECT)

SETFMIME-VERSION (NEW-VALUE OBJECT)

PROLOGUE (OBJECT)

SETFPROLOGUE (NEW-VALUE OBJECT)

Private

CONTENT-ENCODING (OBJECT)

Encoding the MIME content is currently in. May be :7BIT :BASE64 or :QUOTED-PRINTABLE

SETFCONTENT-ENCODING (NEW-VALUE OBJECT)

Encoding the MIME content is currently in. May be :7BIT :BASE64 or :QUOTED-PRINTABLE

VARIABLE

Private

Undocumented

*MIME-TYPES-FILE*

CLASS

Public

MIME

Standard MIME Object Representation

MULTIPART-MIME

Multipart Mime Object Representation

TEXT-MIME

Text MIME Object Representation