aboutsummaryrefslogtreecommitdiff
path: root/src/tp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/tp.lua')
-rw-r--r--src/tp.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tp.lua b/src/tp.lua
index 4f2a615..b671e58 100644
--- a/src/tp.lua
+++ b/src/tp.lua
@@ -20,20 +20,20 @@ TIMEOUT = 60
20 20
21-- gets server reply (works for SMTP and FTP) 21-- gets server reply (works for SMTP and FTP)
22local function get_reply(control) 22local function get_reply(control)
23 local code, current, separator, _ 23 local code, current, sep
24 local line, err = control:receive() 24 local line, err = control:receive()
25 local reply = line 25 local reply = line
26 if err then return nil, err end 26 if err then return nil, err end
27 _, _, code, separator = string.find(line, "^(%d%d%d)(.?)") 27 code, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))
28 if not code then return nil, "invalid server reply" end 28 if not code then return nil, "invalid server reply" end
29 if separator == "-" then -- reply is multiline 29 if sep == "-" then -- reply is multiline
30 repeat 30 repeat
31 line, err = control:receive() 31 line, err = control:receive()
32 if err then return nil, err end 32 if err then return nil, err end
33 _,_, current, separator = string.find(line, "^(%d%d%d)(.?)") 33 current, sep = socket.skip(2, string.find(line, "^(%d%d%d)(.?)"))
34 reply = reply .. "\n" .. line 34 reply = reply .. "\n" .. line
35 -- reply ends with same code 35 -- reply ends with same code
36 until code == current and separator == " " 36 until code == current and sep == " "
37 end 37 end
38 return code, reply 38 return code, reply
39end 39end