((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/mbox" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.") (tags "eggs") (toc)) (section 2 "mbox" (section 3 "Description" (p "The " (tt "mbox") " library contains procedures for parsing of mbox database files, " (link "http://tools.ietf.org/html/rfc4155" "RFC 4155") ". It is intended to conform closely to the ABNF grammar in the RFC.")) (section 3 "Library Procedures" (section 4 "Message Predicates and Accessors" (p "The parsing procedures in this library return a list of message objects. The following procedures are available for manipulating the message objects:") (def (sig (procedure "(message? X) => BOOL" (id message?))) (p "Returns " (tt "#t") " if the given argument is a message object, " (tt "#f") " otherwise.")) (def (sig (procedure "(message-envelope X) => ENVELOPE" (id message-envelope))) (p "Returns the envelope part of a message. The envelope is an s-expression of the following form:") (pre "((time-seconds R) [(ctime ...) | (abbrtime ...)] (address ADDRESS))") (p "The " (tt "time-seconds") " field contains the time when the message was received, in seconds since 1900. The " (tt "ctime") " or " (tt "abbrtime") " fields contain the components of the date/time string. The address fields is an s-expression of the form:") (pre " ((local-part STRING) (domain STRING))")) (def (sig (procedure "(message-headers X) => (LAMBDA () => HEADERS)" (id message-headers))) (p "Returns the headers part of a message. This is a procedure of no arguments that when invoked, returns the parsed list of headers in an alist where the key is the header name (as a symbol), and the value is the parsed header contents.")) (def (sig (procedure "(message-body X) => (LAMBDA ([P]) => BODY)" (id message-body))) (p "Returns the body part of a message. This is a procedure of a single argument, that when invoked, uses the given argument procedure to parse the message body, and returns the result."))) (section 4 "Parsing Procedures: Preliminaries" (p "The parsing procedures in " (tt "mbox") " come in two flavors: generic and specialized for operations on strings.") (p "The " (tt "<Mbox>") " typeclass defined in module " (tt "mbox") " provides generic parsing procedures. Please see the " (int-link "typeclass") " library for information on type classes.  The " (tt "<Mbox>") " typeclass is intended to provide abstraction over different kinds of input sequences, e.g. character lists, strings, streams, etc. " (tt "<Mbox>") " inherits from " (tt "<CoreABNF>") ", which provides the core parsing primitives used to build the mbox grammar parser (see the " (int-link "abnf") " and " (int-link "internet-message") " libraries for more information).") (p "The procedures in module " (tt "mbox-string") " operate on strings. They do not require the instantiaton of type classes and are meant to provide \"turn key\" parsing.")) (section 4 ("Parsing Procedures: " (tt "mbox-string")) (def (sig (procedure "(mbox-file->messages FILENAME-OR-PORT) => MESSAGE LIST" (id mbox-file->messages))) (p "Given a filename or port, parses the given file as an mbox database, and returns a list of message objects. The contents of the message are represented as a string."))) (section 4 ("Parsing Procedures: " (tt "mbox")) (p "The " (tt "<Mbox>") " typeclass has the following definition:") (highlight scheme "(define-class <Mbox> (<InetMessage> M) \n  mbox-envelope\n  mbox-message-fields\n  mbox-message\n  mbox-file->messages )") (p "The following example illustrates the creation of an instance of " (tt "<Mbox>") " typeclass specialized for byte blobs (see " (int-link "byte-blob") ").") (highlight scheme "(require-extension typeclass input-classes byte-blob)\n\n(require-library abnf internet-message mbox)\n(import (only abnf <CoreABNF>  <Token> <CharLex> \n\t      CharLex->CoreABNF Input->Token \n\t      Token->CharLex \n\t      )\n\t(only internet-message <InetMessage> CoreABNF->InetMessage)\n\t(only mbox <Mbox> Input+.CoreABNF->Mbox)\n\t)\n\n\n(define byte-blob-<Input>\n  (make-<Input> byte-blob-empty? \n\t\t(compose byte->char byte-blob-car)\n\t\tbyte-blob-cdr))\n\n(define byte-blob-<Token>\n  (Input->Token byte-blob-<Input>))\n\n(define byte-blob-<CharLex>\n  (Token->CharLex byte-blob-<Token>))\n\n(define byte-blob-<CoreABNF>\n  (CharLex->CoreABNF byte-blob-<CharLex>))\n\n(define byte-blob-<InetMessage>\n  (CoreABNF->InetMessage byte-blob-<CoreABNF> ))\n\n(define byte-blob-<Input+>\n  (make-<Input+> byte-blob-<Input> \n\t\t byte-blob-find\n\t\t (compose blob->byte-blob string->blob)\n\t\t file->byte-blob\n\t\t ))\n\n(define byte-blob-<Mbox>\n  (Input+.CoreABNF->Mbox byte-blob-<Input+>\n\t\t\t byte-blob-<CoreABNF>\n\t\t\t ))"))) (section 3 "Requires" (ul (li (int-link "abnf")) (li (int-link "internet-message")) (li (int-link "internet-timestamp")))) (section 3 "Version History" (ul (li "3.2 Created mbox-string module") (li "3.1 Bug fixes in use of byte-blob") (li "3.0 Compatibility with abnf 5") (li "1.2 Improved handling of address without domain part") (li "1.1 Initial Release"))) (section 3 "License" (pre " Copyright 2010-2017 Ivan Raikov.") (pre " This program is free software: you can redistribute it and/or\n modify it under the terms of the GNU General Public License as\n published by the Free Software Foundation, either version 3 of the\n License, or (at your option) any later version.") (pre " This program is distributed in the hope that it will be useful, but\n WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n General Public License for more details.") (pre " A full copy of the GPL license can be found at\n <http://www.gnu.org/licenses/>."))))