Skip to content

Instantly share code, notes, and snippets.

@earl
Created January 20, 2010 01:26
Show Gist options
  • Save earl/281497 to your computer and use it in GitHub Desktop.
Save earl/281497 to your computer and use it in GitHub Desktop.
--- scripts/prot-imap.r.0.0.3 2010-01-20 01:46:16.136278414 +0100
+++ scripts/prot-imap.r 2010-01-20 02:16:27.824332402 +0100
@@ -110,34 +110,11 @@
CAPABILITY [
; need to parse the multiline response
- foreach res parse/all response crlf [
- if all [res not empty? res] [
- either client/locals/capability [
- case [
- find client/locals/capability "AUTH=CRAM-MD5" [
- cmd-write client rejoin [incr-generator client " AUTHENTICATE CRAM-MD5"]
- client/spec/state: 'CRAM-MD5
- ]
- find client/locals/capability "AUTH=LOGIN" [
- ; this is not correct
- cmd-write client rejoin [ incr-generator client reform [" LOGIN" client/spec/user client/spec/pass]]
- client/spec/state: 'LOGIN
- ]
- find client/locals/capability "AUTH=DIGEST-MD5" [
- ; this to be done
-
- ]
- find client/locals/capability "AUTH=PLAIN" [
- cmd-write client rejoin [ incr-generator client reform [" LOGIN" client/spec/user client/spec/pass]]
- client/spec/state: 'LOGIN
- ]
- ]
- ] [
- net-log "saved capability"
- client/locals/capability: response
- ;read client
- ]
- ]
+ either find response generator [
+ cmd-write client rejoin [ incr-generator client reform [" LOGIN" client/spec/user client/spec/pass]]
+ client/spec/state: 'LOGIN
+ ] [
+ read client
]
]
@@ -227,14 +204,12 @@
]
LIST [
- use [ msg ][
msg: last parse/all trim/tail response CRLF
if match-mark msg generator [
net-log "recvd LIST"
client/spec/state: 'ready
return true
]
- ]
]
READY [
@@ -303,25 +278,13 @@
port [port!]
/local conn
] [
- either any-function? :port/awake [
- ; unless open? port [cause-error 'Access 'not-open port/spec/ref]
- either not open? port [
- print "opening & waiting on port"
- wait open port/state/connection
- ] [
- print "waiting on port"
- ;wait [ port/state/connection port/spec/timeout ]
- wait [ port port/spec/timeout ] ; /state/connection
- ]
- port
- ] [
- print "doing something sync"
- ; do something synchronous here
- ]
+ wait port/state/connection
+ port
]
write: funct [port [port!] data [block!]] [
write-cmdport/only port data
+ read port/state/connection
]
length?: func [ port [port!]][
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment