process ( -- )


Vocabulary
pop3.server

Inputs
None

Outputs
None

Definition


: process ( -- )
read-crlf {
{
[ dup "USER" head? ]
[ "+OK Password required\r\n" write flush t ]
}
{
[ dup "PASS" head? ]
[ "+OK Logged in\r\n" write flush t ]
}
{
[ dup "CAPA" = ]
[
"+OK\r\nCAPA\r\nTOP\r\nUIDL\r\n.\r\n" write
flush t
]
}
{ [ dup "STAT" = ] [ "+OK 2 1753\r\n" write flush t ] }
{
[ dup "LIST" = ]
[
"+OK 2 messages:\r\n1 1006\r\n2 747\r\n.\r\n"
write flush t
]
}
{
[ dup "UIDL" head? ]
[
{
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
[
"+OK\r\n1 000000d547ac2fc2\r\n2 000000d647ac2fc2\r\n.\r\n"
write flush t
]
} cond
]
}
{
[ dup "TOP" head? ]
[
{
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
} cond
]
}
{
[ dup "RETR" head? ]
[
{
{ ~quotation~ ~quotation~ }
{ ~quotation~ ~quotation~ }
} cond
]
}
{
[ dup "DELE" head? ]
[ "+OK Marked for deletion\r\n" write flush t ]
}
{ [ dup "RSET" = ] [ "+OK\r\n" write flush t ] }
{
[ dup "QUIT" = ]
[
"+OK POP3 server closing connection\r\n" write
flush f
]
}
} cond nip [ process ] when ;