Created
January 12, 2010 01:37
-
-
Save earl/274796 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- scripts/prot-ftp.r.orig 2010-01-12 02:35:03.646150037 +0100 | |
+++ scripts/prot-ftp.r 2010-01-12 02:58:26.453609012 +0100 | |
@@ -2,7 +2,7 @@ | |
file: %prot-ftp.r | |
author: "Graham Chiu" | |
date: [10-Jan-2010 .. 12-Jan-2010] | |
- version: 0.0.5 | |
+ version: 0.0.6 | |
rights: 'BSD | |
notes: { | |
doesn't do much! See script at end | |
@@ -209,7 +209,7 @@ | |
cmd-write cmdport data | |
remove cmdport/spec/messages | |
; re-activate the port handler | |
- wait cmdport | |
+ read cmdport | |
] | |
] | |
@@ -258,7 +258,6 @@ | |
"230 " [ | |
print "logged in okay" | |
client/spec/ready: true | |
- write-cmdport/only client [SYST] | |
] | |
] [process-code code client] | |
@@ -365,6 +364,7 @@ | |
binary! [] | |
file! [] | |
] [print to-string port/data] | |
+ close port | |
return true | |
] | |
] [true] | |
@@ -382,16 +382,16 @@ | |
] | |
] [net-log join "Unknown state " client/spec/state] | |
; we've completed a read, now ask for another one | |
- read client | |
+ unless client/spec/ready [read client] | |
] | |
wrote [ | |
net-log "wrote to port, now read from it" | |
- read event/port | |
+ read client | |
] | |
close [net-log "Port closed on me"] | |
] | |
- write-cmdport event/port | |
- false | |
+ write-cmdport client | |
+ client/spec/ready | |
] | |
actor: [ | |
open: func [ | |
@@ -460,50 +460,23 @@ | |
port | |
] | |
- read: func [ | |
- port [port!] | |
- /local conn | |
- ] [ | |
- conn: port/state/connection | |
- either any-function? :port/awake [ | |
- ; unless open? port [cause-error 'Access 'not-open port/spec/ref] | |
- either not open? port [ | |
- print "opening & waiting on subport" | |
- wait [open conn conn/spec/timeout] | |
- ] [ | |
- print "waiting on dataport" | |
- ; we decide whether we are reading from the dataport or the command port based on the state | |
- either find [LIST RETR] conn/spec/state [ | |
- ; keep reading until the dataport is closed | |
- while [not conn/spec/dataport/spec/closed?] [ | |
- net-log "sending another read ..." | |
- read conn | |
- wait conn | |
- ] | |
- ] [ | |
- wait [conn conn/spec/timeout] | |
- ] | |
- ] | |
- port | |
- ] [ | |
- print "doing something sync" | |
- ; do something synchronous here | |
- ] | |
+ read: func [port [port!]] [ | |
+ wait port/state/connection | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment