Changeset 15903 in project


Ignore:
Timestamp:
09/15/09 13:29:18 (10 years ago)
Author:
Ivan Raikov
Message:

updated smtp documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/smtp

    r15893 r15903  
    1313=== Data Types for SMTP Commands
    1414
     15Represenation of SMTP commands:
    1516 
    1617 (define-datatype cmd cmd?
     
    3233  (WrongArg (cmd string?)  (message string?)))
    3334
     35The record printer defined for this datatype prints values of this
     36type in a format conforming to the RFC. For example:
     37
     38  csi> (print (Helo "myhost.org"))
     39  HELO myhost.org
     40
     41The {{mailbox}} datatype has the following definition:
    3442
    3543 (define-datatype mailbox mailbox?
    3644   (Mailbox (local-part string?)
    37             (domain string?)))
     45            (domain string?)))
    3846
    3947
    4048=== Data Types for SMTP Replies
     49
     50Representation of SMTP replies:
    4151
    4252  (define-datatype reply reply?
    4353   (Reply (code code?) (msg list?)))
     54
     55
     56An SMTP reply is a three-digit return code plus comments. This is what
     57the list of strings is for; one string per line in the reply.  the
     58record printer will append an CRLF end-of-line marker to each entry in
     59that list, so that the resulting string is ready to be sent back to
     60the peer.
     61
     62
     63For example:
     64
     65 > (print (Reply (Code (Success) (MailSystem) 0)
     66                     (list "worked" "like" "a charm")))
     67 250-worked
     68 250-like
     69 250 a charm
     70
     71
     72The {{code}} datatype consists of success code, category and
     73supplemental code:
     74
     75 (define-datatype code code?
     76   (Code (suc success-code?) (cat category?) (num integer?)))
     77
     78In addition, the {{success-code}} and {{category}} datatypes can be
     79used to map symbolic identifiers to integers and vice versa:
    4480
    4581 (define-enumerated-type
     
    6399   (MailSystem))
    64100
    65  (define-datatype code code?
    66    (Code (suc success-code?) (cat category?) (num integer?)))
    67 
    68 An SMTP reply is a three-digit return code plus comments. This is what
    69 the list of strings is for; one string per line in the reply.  the
    70 record printer will ppend an CRLF end-of-line marker to each entry in
    71 that list, so that the resulting string is ready to be sent back to
    72 the peer.
    73 
    74 
    75 For example:
    76 
    77  > (print (Reply (Code (Success) (MailSystem) 0)
    78                      (list "worked" "like" "a charm")))
    79  250-worked
    80  250-like
    81  250 a charm
    82 
    83 
    84 === Command Parsers
    85 
    86  (define (parse-cmd cont)
     101{{define-enumerated-type}} defines a new record type, with as many
     102instances as there are instance names. {{name-vector}} is bound to a
     103vector containing the instances of the type in the same order as the
     104{{instance-name}} list. {{name-inject}} and {{name-project}} are
     105procedures that map integers to an instance and vice versa.
    87106
    88107=== ESMTP State Machine
    89108
    90  start-session session-fsm?
    91 
    92  (define-datatype session-state session-state?
    93    (Unknown)
    94    (HaveHelo)
    95    (HaveMailFrom)
    96    (HaveRcptTo)
    97    (HaveData)
    98    (HaveQuit))
     109<procedure>(start-session)</procedure>
     110
     111Procedure {{start-session}} returns an ESMTP state machine object (a
     112procedure), which takes in a stream containing an SMTP command and
     113returns an appropriate {{session-fsm}} value:
     114
     115  (define-datatype session-fsm session-fsm?
     116    (Event (ev event?))
     117    (Trans (ev event?) (fsm procedure?)))
     118
     119A stream in this case is defined as the representation used by the
     120[[abnf]] library.
     121
     122The {{Event}} variant signals an event that must be processed by the
     123calling library, while {{Trans}} signals an event and a state machine
     124transition. The following events can be returned by this state
     125machine:
    99126
    100127 (define-datatype event event?
     
    116143   (SyntaxErrorIn (s string?))
    117144   (Unrecognized  (s string?)))
     145
     146
    118147
    119148=== Requires
Note: See TracChangeset for help on using the changeset viewer.