aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-07-01 03:47:22 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-07-01 03:47:22 +0000
commit596602f2caa75dc119fe7071fc74bafdca32bfde (patch)
tree96909f0688bb34bec8d1b6430a8c72febf752f5b
parent1812d6ce150d9661bac858b82f81e133409b8409 (diff)
downloadluasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.tar.gz
luasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.tar.bz2
luasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.zip
Seems good.
-rw-r--r--etc/lp.lua8
-rw-r--r--samples/lpr.lua7
-rw-r--r--src/usocket.c2
3 files changed, 10 insertions, 7 deletions
diff --git a/etc/lp.lua b/etc/lp.lua
index 14ffc70..5230957 100644
--- a/etc/lp.lua
+++ b/etc/lp.lua
@@ -76,7 +76,7 @@ RFC 1179
76-- gets server acknowledement 76-- gets server acknowledement
77local function recv_ack(con) 77local function recv_ack(con)
78 local ack = con.skt:receive(1) 78 local ack = con.skt:receive(1)
79 con.try(string.char(0) == ack, "failed to receive server acknowledement") 79 con.try(string.char(0) == ack, "failed to receive server acknowledgement")
80end 80end
81 81
82-- sends client acknowledement 82-- sends client acknowledement
@@ -166,7 +166,7 @@ local function send_hdr(con, control)
166end 166end
167 167
168local function send_control(con, control) 168local function send_control(con, control)
169 local sent = con:send(control) 169 local sent = con.skt:send(control)
170 con.try(sent and sent >= 1, "failed to send control file") 170 con.try(sent and sent >= 1, "failed to send control file")
171 send_ack(con) 171 send_ack(con)
172end 172end
@@ -176,7 +176,7 @@ local function send_data(con,fh,size)
176 while size > 0 do 176 while size > 0 do
177 buf,message = fh:read(8192) 177 buf,message = fh:read(8192)
178 if buf then 178 if buf then
179 st = con.try(con:send(buf)) 179 st = con.try(con.skt:send(buf))
180 size = size - st 180 size = size - st
181 else 181 else
182 con.try(size == 0, "file size mismatch") 182 con.try(size == 0, "file size mismatch")
@@ -303,7 +303,7 @@ query = socket.protect(function(p)
303 if string.sub(p.format or 's',1,1) == 's' then fmt = 3 else fmt = 4 end 303 if string.sub(p.format or 's',1,1) == 's' then fmt = 3 else fmt = 4 end
304 con.try(con.skt:send(string.format("%c%s %s\n", fmt, p.queue or "*", 304 con.try(con.skt:send(string.format("%c%s %s\n", fmt, p.queue or "*",
305 p.list or ""))) 305 p.list or "")))
306 local data = ltry(connection:receive("*a")) 306 local data = con.try(con.skt:receive("*a"))
307 con.skt:close() 307 con.skt:close()
308 return data 308 return data
309end) 309end)
diff --git a/samples/lpr.lua b/samples/lpr.lua
index 77c354f..c23ebee 100644
--- a/samples/lpr.lua
+++ b/samples/lpr.lua
@@ -1,7 +1,7 @@
1local lp = require("lp") 1local lp = require("lp")
2 2
3local function usage() 3local function usage()
4 print('\nUsage: lp filename [keyword=val...]\n') 4 print('\nUsage: lua lptest.lua [filename] [keyword=val...]\n')
5 print('Valid keywords are :') 5 print('Valid keywords are :')
6 print( 6 print(
7 ' host=remote host or IP address (default "localhost")\n' .. 7 ' host=remote host or IP address (default "localhost")\n' ..
@@ -36,12 +36,13 @@ do
36 if not arg[2] then 36 if not arg[2] then
37 return usage() 37 return usage()
38 end 38 end
39
39 if arg[1] ~= "query" then 40 if arg[1] ~= "query" then
40 r,e=lp.send(arg[1],opt) 41 r,e=lp.send(arg[1],opt)
41 io.stderr:write(tostring(r or e),'\n') 42 io.stdout:write(tostring(r or e),'\n')
42 else 43 else
43 r,e=lp.query(opt) 44 r,e=lp.query(opt)
44 io.stderr:write(tostring(r or e), '\n') 45 io.stdout:write(tostring(r or e), '\n')
45 end 46 end
46end 47end
47 48
diff --git a/src/usocket.c b/src/usocket.c
index 12a13a5..b99eaa8 100644
--- a/src/usocket.c
+++ b/src/usocket.c
@@ -347,5 +347,7 @@ const char *sock_strerror(void) {
347} 347}
348 348
349const char *sock_geterr(p_sock ps, int code) { 349const char *sock_geterr(p_sock ps, int code) {
350 (void) ps;
351 (void) code;
350 return sock_strerror(); 352 return sock_strerror();
351} 353}