QoK      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ(c) 2013 Peter SimonsBSD3simons@cryp.to provisionalportableSafe:%Case-insensitive variant of Parsec's K function.%Case-insensitive variant of Parsec's L function.Match a parser at least n times.Match a parser at least n times, but no more than m times.Helper function to generate Parser-based instances for the M class.$Match any character of the alphabet.Match either "1" or "0".KMatch any 7-bit US-ASCII character except for NUL (ASCII value 0, that is).$Match the carriage return character \r. %Match returns the linefeed character \n. Match the Internet newline \r\n. nMatch any US-ASCII control character. That is any character with a decimal value in the range of [0..31,127]. "Match the double quote character """. gMatch any character that is valid in a hexadecimal number; ['0'..'9'] and ['A'..'F','a'..'f'] that is.Match the tab ("\t ") character.?Match "linear white-space". That is any number of consecutive , optionally followed by a   and (at least) one more .Match any character.Match the space.Match any printable ASCII character. (The "v" stands for "visible".) That is any character in the decimal range of [33..126]. Match either  or .KMatch a "quoted pair". Any characters (excluding CR and LF) may be quoted.%Match a quoted string. The specials "\" and ""L" must be escaped inside a quoted string; CR and LF are not allowed at all.    (c) 2013 Peter SimonsBSD3simons@cryp.to provisionalportableSafe:&An SMTP reply is a three-digit return code plus some waste of bandwidth called "comments". This is what the list of strings is for; one string per line in the reply. N will append an "\r\n" end-of-line marker to each entry in that list, so that the resulting string is ready to be sent back to the peer. For example:Gshow $ Reply (Code Success MailSystem 0) ["worked", "like", "a charm" ]+"250-worked\r\n250-like\r\n250 a charm\r\n" If the message is an empty list []%, a default text will be constructed:+show $ Reply (Code Success MailSystem 0) []("250 Success in category MailSystem\r\n"(/The most general e-mail address has the form: <[@route,...:]user@domain>. This type, too, supports N and O". Note that a "shown" address is alwaysl enclosed in angular brackets. When comparing two mailboxes for equality, the hostname is case-insensitive.*The _= parser will create this data type from a string. Note that all; command parsers expect their input to be terminated with  .- Might be Y.. Might be Z.6 Might be [].7Optional argument ignored.:pWhen a valid command has been recognized, but the argument parser fails, then this type will be returned. The P? contains the name of the command (in all upper-case) and the Q' is, obviously, the error description.=reserved for the userEreserved for the userI9, 1, 2, 3, 4, and 5.KTriggered in case of 7 or when 0& is used before we even have a state.LThe parameter may be [].W&Parse a line of SMTP dialogue and run X to determine the <. In case of syntax errors, N or O3 will be returned. Inputs must be terminated with  . See .X For those who want to parse the *' themselves. Calling this function in V or U will fail an assertion. If R+ is disabled, it will return respectively M and D again.YnullPath = ( [] "" "" = "<>"Z postmaster = ($ [] "postmaster" "" = "<postmaster>"[ Construct a S. Fails R if invalid numbers are given.\<A reply constitutes "success" if the status code is any of ,  , or !.]<A reply constitutes "failure" if the status code is either # or ".^ The replies 221 and 421 signify M._wThe SMTP parsers defined here correspond to the commands specified in RFC2821, so I won't document them individually.JThis parser recognizes any of the SMTP commands defined below. Note that all; command parsers expect their input to be terminated with  .`!The parser name "data" was taken.nMay have an optional  argument, but it is ignored.wTODO': Add IPv6 address and general literals1This is a useful addition: The parser accepts an | or a .Make the string   terminated no matter what. '\n' is expanded, otherwise   is appended. Note that if the string was terminated incorrectly before, it still is. This function is useful when reading input with * which removes the end-of-line delimiter.=Construct a parser for a command without arguments. Expects  !Construct a parser for a command with an argument, which the given parser will handle. The result of the argument parser will be applied to the type constructor before it is returned. Expects  !t !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~n !"#$%&'()*/:8791234560+,-.;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~tPQRSTUV<=>?@ABCDEFGHIJKLMNO;WX*+,-./0123456789:()YZ&'$% !"#[\]^_`abcdefghijklmnopqrstuvwxyz{|}~< !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~(c) 2013 Peter SimonsBSD3simons@cryp.to provisionalportableSafe:This data type represents any of the header fields defined in this RFC. Each of the various instances contains with the return value of the corresponding parser.This data type repesents a parsed Internet Message as defined in this RFC. It consists of an arbitrary number of header lines, represented in the 4 data type, and a message body, which may be empty.CA NameAddr is composed of an optional realname a mandatory e-mail .Return Nothingg if the given parser doesn't match. This combinator is included in the latest parsec distribution as  optionMaybe+, but ghc-6.6.1 apparently doesn't have it.unfold = 'between (optional cfws) (optional cfws)_Construct a parser for a message header line from the header's name and a parser for the body.Like ,, but allows the obsolete white-space rules.4Match any US-ASCII non-whitespace control character.(Match any US-ASCII character except for r, n.-Match any of the RFC's "special" characters:  ()<>[]:;@,.\".1Match a "quoted pair". All characters matched by / may be quoted. Note that the parsers returns both3 characters, the backslash and the actual content.7Match "folding whitespace". That is any combination of  and   followed by .<Match any non-whitespace, non-control character except for "(", ")", and "\2". This is used to describe the legal content of s.Note: This parser accepts 8-bit characters, even though this is not legal according to the RFC. Unfortunately, 8-bit content in comments has become fairly common in the real world, so we'll just accept the fact./Match a "comments". That is any combination of , s, and % between brackets. Comments may nest.Match any combination of  and .=Match any US-ASCII character except for control characters,  , or space.  and  are made up of this.Match one or more 1 characters and skip any preceeding or trailing .Match % and skip any preceeding or trailing .Match two or more s interspersed by dots.FMatch any non-whitespace, non-control US-ASCII character except for "\" and """. Match either  or .Match any number of  between double quotes. Any > preceeding or following the "atom" is skipped automatically. Match either  or .Match either one or more s or an .FMatch any non-whitespace, non-control US-ASCII character except for "\" and """.Match any number of  tokens.8"Unstructured text" is used in free text fields such as T. Please note that any comments or whitespace that prefaces or follows the actual  is included in the returned string./Parse a date and time specification of the form ! Thu, 19 Dec 2002 20:35:46 +0200!where the weekday specification "Thu,%" is optional. The parser returns a TP, which is set to the appropriate values. Note, though, that not all fields of Tv will necessarily be set correctly! Obviously, when no weekday has been provided, the parser will set this field to Uz - regardless of whether the day actually is a monday or not. Similarly, the day of the year will always be returned as 0+. The timezone name will always be empty: "". Nor will the  parser perform any& consistency checking. It will accept  40 Apr 2002 13:12 +0100as a perfectly valid date.In order to get all fields set to meaningful values, and in order to verify the date's consistency, you will have to feed it into any of the conversion routines provided in  System.Time , such as V=. (When doing this, keep in mind that most functions return  local time;. This will not necessarily be the time you're expecting.)This parser matches a  or an < (optionally wrapped in folding whitespace) and return its W value.1This parser will the abbreviated weekday names ("Mon", "Tue$", ...) and return the appropriate W value.+This parser will match a date of the form " dd:mm:yyyyY" and return a tripple of the form (Int,Month,Int) - corresponding to (year,month,day).iThis parser will match a four digit number and return its integer value. No range checking is performed.This parser will match a 3, optionally wrapped in folding whitespace, or an  and return its X value./This parser will the abbreviated month names ("Jan", "Feb$", ...) and return the appropriate X value.cMatch a 1 or 2-digit number (day of month), recognizing both standard and obsolete folding syntax.This parser will match a  specification followed by a [. It returns the tuple (TimeDiff,Int) corresponding to the return values of either parser.7This parser will match a time-of-day specification of "hh:mm" or "hh:mm:ss(" and return the corrsponding time as a Y.hThis parser will match a two-digit number and return its integer value. No range checking is performed.hThis parser will match a two-digit number and return its integer value. No range checking is performed.gThis parser will match a two-digit number and return its integer value. No range checking takes place.>This parser will match a timezone specification of the form "+hhmm" or "-hhmmA" and return the zone's offset to UTC in seconds as an integer. # is matched as well.Parse a single  or an address  and return the address(es).Parse a  or an  and return the address. Parse an , optionally prefaced with a , and return the address. Parse an  or an $ and return the address.(Parse a "group" of addresses. That is a 1, followed by a colon, optionally followed by a g, followed by a semicolon. The found address(es) are returned - what may be none. Here is an example:@parse group "" "my group: user1@example.org, user2@example.org;"Right [NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user1@example.org"},NameAddr {nameAddr_name = Nothing, nameAddr_addr = "user2@example.org"}]Parse and return a .Parse a list of f addresses, every two addresses being separated by a comma, and return the list of found address(es).Parse a list of f addresses, every two addresses being separated by a comma, and return the list of found address(es).,Parse an "address specification". That is a , followed by an "@" character, followed by a ". Return the complete address as P*, ignoring any whitespace or any comments.&Parse and return a "local part" of an . That is either a  or a .'Parse and return a "domain part" of an . That is either a  or a .%Parse a "domain literal". That is a "[(" character, followed by any amount of , followed by a terminating "]7" character. The complete string is returned verbatim.5Parse and return any characters that are legal in a  . That is  or a ..Parse and return any ASCII characters except "[", "] ", and "\".Parse a complete message as defined by this RFC and it broken down into the separate header fields and the message body. Header lines, which contain syntax errors, will not cause the parser to abort. Rather, these headers will appear as )s (which are unparsed) in the resulting I. A message must be really, really badly broken for this parser to fail.This behaviour was chosen because it is impossible to predict what the user of this module considers to be a fatal error; traditionally, parsers are very forgiving when it comes to Internet messages.If you want to implement a really strict parser, you'll have to put the appropriate parser together yourself. You'll find that this is rather easy to do. Refer to the  parser for further details.>A message body is just an unstructured sequence of characters.tThis parser will parse an arbitrary number of header fields as defined in this RFC. For each field, an appropriate . value is created, all of them making up the  list that this parser returns.WIf you look at the implementation of this parser, you will find that it uses Parsec's Z modifier around allo of the fields. The idea behind this is that fields, which contain syntax errors, fall back to the catch-all . Thus, this parser will hardly ever return a syntax error -- what conforms with the idea that any message that can possibly be accepted should be. Parse a "Date:1" header line and return the date it contains a T. Parse a "From:" header line and return the  address(es) contained in it. Parse a "Sender:" header line and return the  address contained in it. Parse a " Reply-To:" header line and return the  address(es) contained in it. Parse a "To:" header line and return the  address(es) contained in it. Parse a "Cc:" header line and return the  address(es) contained in it. Parse a "Bcc:" header line and return the  address(es) contained in it. Parse a " Message-Id:" header line and return the  contained in it. Parse a " In-Reply-To:&" header line and return the list of s contained in it. Parse a " References:&" header line and return the list of s contained in it. Parse a " message ID:9" and return it. A message ID is almost identical to an 8, but with stricter rules about folding and whitespace.Parse a "left ID" part of a #. This is almost identical to the M of an e-mail address, but with stricter rules about folding and whitespace.Parse a "right ID" part of a #. This is almost identical to the M of an e-mail address, but with stricter rules about folding and whitespace. Parse one or more occurences of  or 8 and return the concatenated string. This makes up the  of a . Parse one or more occurences of  or 8 and return the concatenated string. This makes up the  of a . Parse a "Subject:" header line and return its contents verbatim. Please note that all whitespace and/or comments are preserved, i.e. the result of parsing "Subject: foo" is " foo", not "foo". Parse a " Comments:" header line and return its contents verbatim. Please note that all whitespace and/or comments are preserved, i.e. the result of parsing "Comments: foo" is " foo", not "foo". Parse a " Keywords:%" header line and return the list of 9s found. Please not that each phrase is again a list of s, as returned by the  parser. Parse a " Resent-Date:2" header line and return the date it contains as T. Parse a " Resent-From:" header line and return the  address(es) contained in it. Parse a "Resent-Sender:" header line and return the  address(es) contained in it. Parse a " Resent-To:" header line and return the  address contained in it. Parse a " Resent-Cc:" header line and return the  address(es) contained in it.  Parse a " Resent-Bcc:" header line and return the 8 address(es) contained in it. (This list may be empty.)  Parse a "Resent-Message-ID:" header line and return the  contained in it.CParse an arbitrary header field and return a tuple containing the  and $ text of the header. The name will not contain the terminating colon.FParse and return an arbitrary header field name. That is one or more  characters.VMatch and return any ASCII character except for control characters, whitespace, and ":".9Match the obsolete "quoted pair" syntax, which - unlike  - allowed anyt ASCII character to be specified when quoted. The parser will return both, the backslash and the actual character.1Match the obsolete "text" syntax, which - unlike  - allowed "carriage returns" and "linefeeds". This is really weird; you better consult the RFC for details. The parser will return the complete string, including those special characters.=Match and return the obsolete "char" syntax, which - unlike 2 - did not allow "carriage return" and "linefeed".EMatch and return the obsolete "utext" syntax, which is identical to .3Match the obsolete "phrase" syntax, which - unlike  - allows dots between tokens.5Match a "phrase list" syntax and return the list of P-s that make up the phrase. In contrast to a , the a separates the individual words by commas. This syntax is - as you will have guessed - obsolete.@Parse and return an "obsolete fws" token. That is at least one A character, followed by an arbitrary number (including zero) of   followed by at least one more  character.Parse a + but allow for the obsolete folding syntax.Parse a N but allow for a two-digit number (obsolete) and the obsolete folding syntax.Parse a + but allow for the obsolete folding syntax.Parse a + but allow for the obsolete folding syntax. Parse a + but allow for the obsolete folding syntax.!Parse a + but allow for the obsolete folding syntax."Parse a + but allow for the obsolete folding syntax.#@Match the obsolete zone names and return the appropriate offset.$This parser matches the "obsolete angle address" syntax, a construct that used to be called "route address" in earlier RFCs. It differs from a standard  in two ways: (1) it allows far more liberal insertion of folding whitespace and comments and (2) the address may contain a "route" (which this parser ignores):Gparse obs_angle_addr "" "<@example1.org,@example2.org:joe@example.org>"Right "<joe@example.org>"%'This parser parses the "route" part of $ and returns the list of P&s that make up this route. Relies on & for the actual parsing.&This parser parses a list of domain names, each of them prefaced with an "at". Multiple names are separated by a comma. The list of !s is returned - and may be empty.'Parse the obsolete syntax of a o, which allowed for more liberal insertion of folding whitespace and comments. The actual string is returned.(Parse the obsolete syntax of a o, which allowed for more liberal insertion of folding whitespace and comments. The actual string is returned.)1This parser will match the obsolete syntax for a . This one is quite weird: An )" contains an arbitrary number of ves - including none -, which are separated by commas. But you may have multiple consecutive commas without giving a . You may also have a valid ) that contains no  at all. On the other hand, you must: have at least one comma. The following example is valid:parse obs_mbox_list "" ","Right []But this one is not:(parse obs_mbox_list "" "joe@example.org"Left (line 1, column 16):unexpected end of input1expecting obsolete syntax for a list of mailboxes*This parser is identical to ) but parses a list of es rather than $es. The main difference is that an  may contain us. Please note that as of now, the parser will return a simple list of addresses; the grouping information is lost.,Parse a 8 header line but allow for the obsolete folding syntax.-Parse a 8 header line but allow for the obsolete folding syntax..Parse a 8 header line but allow for the obsolete folding syntax./Parse a 8 header line but allow for the obsolete folding syntax.0Parse a 8 header line but allow for the obsolete folding syntax.1Parse a 8 header line but allow for the obsolete folding syntax.2Parse a 8 header line but allow for the obsolete folding syntax.3Parse a 8 header line but allow for the obsolete folding syntax.4 Parse an P header line but allow for the obsolete folding and the obsolete phrase syntax.5Parse a P header line but allow for the obsolete folding and the obsolete phrase syntax.6aParses the "left part" of a message ID, but allows the obsolete syntax, which is identical to a .7bParses the "right part" of a message ID, but allows the obsolete syntax, which is identical to a .8Parse a 8 header line but allow for the obsolete folding syntax.9Parse a 8 header line but allow for the obsolete folding syntax.:Parse a S header line but allow for the obsolete folding syntax. Also, this parser accepts .;Parse a 8 header line but allow for the obsolete folding syntax.<Parse a 8 header line but allow for the obsolete folding syntax.=Parse a 8 header line but allow for the obsolete folding syntax.>Parse a 8 header line but allow for the obsolete folding syntax.?Parse a 8 header line but allow for the obsolete folding syntax.@Parse a  8 header line but allow for the obsolete folding syntax.AParse a  8 header line but allow for the obsolete folding syntax.BParse a Resent-Reply-To8 header line but allow for the obsolete folding syntax.EMatch $.FThis parser is identical to a but allows the more liberal line-folding syntax between the "field_name" and the "field text".      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEF      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFSafe [\]^_`abcdefg\bcdefg [\]^_`abcdefgh      !"#$%&'()*+,-.//0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~xyz w     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJHIKLMNLOPLQRLSTHUVLSWHX.YZ[YZ\YZ]YZ^YZ_YZ`HXabcdefghijklmno hsemail-2-LClSw1r8qyf3uvWkNM95zeText.Parsec.Rfc2234Text.Parsec.Rfc2821Text.Parsec.Rfc2822 System.IOhGetLine Paths_hsemailcaseChar caseStringmanyNmanyNtoM parsec2readalphabit charactercrlfcrlfctldquotehexdightablwspoctetspvcharwsp quoted_pair quoted_stringCategorySyntax Information Connection Unspecified3 Unspecified4 MailSystem SuccessCodeUnused0PreliminarySuccessSuccessIntermediateSuccessTransientFailurePermanentFailureSmtpCodeCode SmtpReplyReplyMailboxSmtpCmdHeloEhloMailFromRcptToDataRsetSendSomlSamlVrfyExpnHelpNoopQuitTurnWrongArgSmtpdFSMEventGreetingSayHelo SayHeloAgainSayEhlo SayEhloAgain SetMailFrom AddRcptTo StartDataDeliver NeedHeloFirstNeedMailFromFirstNeedRcptToFirst NotImplemened ResetStateSayOK SeeksHelpShutdown SyntaxErrorIn Unrecognized SessionStateUnknownHaveHelo HaveMailFrom HaveRcptToHaveDataHaveQuitsmtpdFSM handleSmtpCmdnullPath postmasterreply isSuccess isFailure isShutdownsmtpCmdsmtpDatarsetquitturnheloehlomailrcptsendsomlsamlvrfyexpnhelpnoop from_pathto_pathpathmailbox local_partdomaina_d_l at_domainaddress_literal ipv4_literalipv4addr subdomain dot_stringatomsnumnumberwordfixCRLFmkCmd0mkCmd1 tokenList$fShowSmtpCode$fShowSmtpReply $fReadMailbox $fShowMailbox $fEqMailbox $fShowSmtpCmd$fEnumSessionState$fBoundedSessionState$fEqSessionState$fOrdSessionState$fShowSessionState $fEqEvent $fShowEvent$fEnumSuccessCode$fBoundedSuccessCode$fEqSuccessCode$fOrdSuccessCode$fShowSuccessCode$fEnumCategory$fBoundedCategory $fEqCategory $fOrdCategory$fShowCategoryField OptionalFieldFromSender ReturnPathReplyToToCcBcc MessageID InReplyTo ReferencesSubjectCommentsKeywordsDate ResentDate ResentFrom ResentSenderResentToResentCc ResentBccResentMessageID ResentReplyToReceived ObsReceivedGenericMessageMessageNameAddr nameAddr_name nameAddr_addr maybeOptionunfoldheader obs_header no_ws_ctltextspecialsfwsctextcommentcfwsatextdot_atom dot_atom_textqtextqcontentphraseutext unstructured date_time day_of_weekday_namedateyearmonth month_name day_of_monthdaytime time_of_dayhourminutesecondzoneaddress name_addr angle_addrgroup display_name mailbox_list address_list addr_specdomain_literaldcontentdtextmessagebodyfields orig_datefromsenderreply_totoccbcc message_id in_reply_to referencesmsg_idid_leftid_right no_fold_quoteno_fold_literalsubjectcommentskeywords resent_date resent_from resent_sender resent_to resent_cc resent_bcc resent_msg_id return_pathreceived name_val_list name_val_pair item_name item_valueoptional_field field_nameftextobs_qpobs_textobs_char obs_utext obs_phraseobs_phrase_listobs_fwsobs_day_of_weekobs_year obs_monthobs_dayobs_hour obs_minute obs_secondobs_zoneobs_angle_addr obs_routeobs_domain_listobs_local_part obs_domain obs_mbox_list obs_addr_list obs_fields obs_orig_dateobs_from obs_sender obs_reply_toobs_toobs_ccobs_bccobs_message_idobs_in_reply_toobs_references obs_id_left obs_id_right obs_subject obs_comments obs_keywordsobs_resent_fromobs_resent_sendobs_resent_date obs_resent_to obs_resent_ccobs_resent_bccobs_resent_midobs_resent_reply obs_return obs_receivedobs_path obs_optional$fShowNameAddr $fEqNameAddr $fShowField$fShowGenericMessage$parsec-3.1.11-37j7M1YEHqtEooY7BpJdriText.Parsec.CharcharstringbaseGHC.ReadReadGHC.Showshow Text.ReadreadGHC.BaseStringText.Parsec.Error ParseErrorassertText.Parsec.Prim'old-time-1.1.0.3-IcvdkJUsE9M8t3io8peAEp System.Time CalendarTimeMonday toClockTimeDayMonthTimeDifftrycatchIOversionbindirlibdirdatadir libexecdir sysconfdir getBinDir getLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName