Monday, November 08, 2010 at 12:06 AM.
system.verbs.builtins.tcp.ftp.readResponse
on readResponse (adrconnectiontable) {
local (buffer = "");
local (done = false);
local (i, ct);
loop { // we read data until the complete command has come in
buffer = buffer + string (tcp.ftp.read (adrconnectiontable^.commandStream));
if buffer endsWith cr+lf { // possibly done
if buffer [4] == " " { // if a space here, we are done
done = true}
else {
ct = sizeOf (buffer);
for i = ct-1 downTo 1 { // back up, looking for previous line's lf character
if buffer[i] == lf { // found it!
if i != ct { // if it's not the first line of multi-line response
if buffer[i+4] == " " { // a multi-line response is done
done = true;
break}}}}}};
if done {
break};
tcp.ftp.yieldProcessor ()};
buffer = string.replaceAll (buffer, cr+lf, cr);
buffer = string.popTrailing (buffer, cr);
if adrconnectiontable^.flmessages {
msg (buffer)};
return (buffer)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.