diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-01 03:47:22 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-01 03:47:22 +0000 |
| commit | 596602f2caa75dc119fe7071fc74bafdca32bfde (patch) | |
| tree | 96909f0688bb34bec8d1b6430a8c72febf752f5b | |
| parent | 1812d6ce150d9661bac858b82f81e133409b8409 (diff) | |
| download | luasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.tar.gz luasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.tar.bz2 luasocket-596602f2caa75dc119fe7071fc74bafdca32bfde.zip | |
Seems good.
| -rw-r--r-- | etc/lp.lua | 8 | ||||
| -rw-r--r-- | samples/lpr.lua | 7 | ||||
| -rw-r--r-- | src/usocket.c | 2 |
3 files changed, 10 insertions, 7 deletions
| @@ -76,7 +76,7 @@ RFC 1179 | |||
| 76 | -- gets server acknowledement | 76 | -- gets server acknowledement |
| 77 | local function recv_ack(con) | 77 | local 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") |
| 80 | end | 80 | end |
| 81 | 81 | ||
| 82 | -- sends client acknowledement | 82 | -- sends client acknowledement |
| @@ -166,7 +166,7 @@ local function send_hdr(con, control) | |||
| 166 | end | 166 | end |
| 167 | 167 | ||
| 168 | local function send_control(con, control) | 168 | local 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) |
| 172 | end | 172 | end |
| @@ -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 |
| 309 | end) | 309 | end) |
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 @@ | |||
| 1 | local lp = require("lp") | 1 | local lp = require("lp") |
| 2 | 2 | ||
| 3 | local function usage() | 3 | local 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 |
| 46 | end | 47 | end |
| 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 | ||
| 349 | const char *sock_geterr(p_sock ps, int code) { | 349 | const char *sock_geterr(p_sock ps, int code) { |
| 350 | (void) ps; | ||
| 351 | (void) code; | ||
| 350 | return sock_strerror(); | 352 | return sock_strerror(); |
| 351 | } | 353 | } |
