Seems good.

This commit is contained in:
Diego Nehab 2004-07-01 03:47:22 +00:00
parent 1812d6ce15
commit 596602f2ca
3 changed files with 10 additions and 7 deletions

View File

@ -76,7 +76,7 @@ RFC 1179
-- gets server acknowledement
local function recv_ack(con)
local ack = con.skt:receive(1)
con.try(string.char(0) == ack, "failed to receive server acknowledement")
con.try(string.char(0) == ack, "failed to receive server acknowledgement")
end
-- sends client acknowledement
@ -166,7 +166,7 @@ local function send_hdr(con, control)
end
local function send_control(con, control)
local sent = con:send(control)
local sent = con.skt:send(control)
con.try(sent and sent >= 1, "failed to send control file")
send_ack(con)
end
@ -176,7 +176,7 @@ local function send_data(con,fh,size)
while size > 0 do
buf,message = fh:read(8192)
if buf then
st = con.try(con:send(buf))
st = con.try(con.skt:send(buf))
size = size - st
else
con.try(size == 0, "file size mismatch")
@ -303,7 +303,7 @@ query = socket.protect(function(p)
if string.sub(p.format or 's',1,1) == 's' then fmt = 3 else fmt = 4 end
con.try(con.skt:send(string.format("%c%s %s\n", fmt, p.queue or "*",
p.list or "")))
local data = ltry(connection:receive("*a"))
local data = con.try(con.skt:receive("*a"))
con.skt:close()
return data
end)

View File

@ -1,7 +1,7 @@
local lp = require("lp")
local function usage()
print('\nUsage: lp filename [keyword=val...]\n')
print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n')
print('Valid keywords are :')
print(
' host=remote host or IP address (default "localhost")\n' ..
@ -36,12 +36,13 @@ do
if not arg[2] then
return usage()
end
if arg[1] ~= "query" then
r,e=lp.send(arg[1],opt)
io.stderr:write(tostring(r or e),'\n')
io.stdout:write(tostring(r or e),'\n')
else
r,e=lp.query(opt)
io.stderr:write(tostring(r or e), '\n')
io.stdout:write(tostring(r or e), '\n')
end
end

View File

@ -347,5 +347,7 @@ const char *sock_strerror(void) {
}
const char *sock_geterr(p_sock ps, int code) {
(void) ps;
(void) code;
return sock_strerror();
}