USING: accessors arrays assocs calendar calendar.english
-calendar.format calendar.parser formatting fry grouping io
-io.crlf io.encodings.ascii io.encodings.binary
-io.encodings.string io.encodings.utf7 io.encodings.utf8
-io.sockets io.sockets.secure io.streams.duplex io.streams.string
-kernel math math.parser multiline pcre sequences
-sequences.extras strings ;
+calendar.format calendar.parser formatting grouping io io.crlf
+io.encodings.ascii io.encodings.binary io.encodings.string
+io.encodings.utf7 io.encodings.utf8 io.sockets io.sockets.secure
+io.streams.duplex io.streams.string kernel math math.parser
+multiline sequences sequences.extras splitting strings ;
QUALIFIED: pcre
IN: imap
! Special parsing
: parse-items ( seq -- items )
- first " " split 2 tail ;
+ first words 2 tail ;
: parse-list-folders ( str -- folder )
[[ \* LIST \(([^\)]+)\) "([^"]+)" "?([^"]+)"?]] pcre:findall
: parse-status ( seq -- assoc )
first [[ \* STATUS "[^"]+" \(([^\)]+)\)]] pcre:findall first last last
- " " split 2 group [ string>number ] assoc-map ;
+ words 2 group [ string>number ] assoc-map ;
: parse-store-mail-line ( str -- pair/f )
[[ \(FLAGS \(([^\)]+)\) UID (\d+)\)]] pcre:findall [ f ] [
- first rest values first2 [ " " split ] dip string>number swap 2array
+ first rest values first2 [ words ] dip string>number swap 2array
] if-empty ;
: parse-store-mail ( seq -- assoc )
drop ;
: status-folder ( mailbox keys -- assoc )
- [ >utf7imap4 ] dip " " join "STATUS \"%s\" (%s)" sprintf
+ [ >utf7imap4 ] dip unwords "STATUS \"%s\" (%s)" sprintf
"" command-response parse-status ;
: close-folder ( -- )