From d55a5826e81136a9ecf65c4cd407152a56684dc2 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Tue, 22 Nov 2005 08:33:29 +0000 Subject: Few tweaks in installation, some missing files, etc. --- samples/cddb.lua | 12 ++++++------ samples/echosrvr.lua | 6 +++--- samples/lpr.lua | 3 ++- samples/tinyirc.lua | 10 +++++----- 4 files changed, 16 insertions(+), 15 deletions(-) (limited to 'samples') diff --git a/samples/cddb.lua b/samples/cddb.lua index 482dc98..883730c 100644 --- a/samples/cddb.lua +++ b/samples/cddb.lua @@ -16,7 +16,7 @@ function parse(body) return nil, code, message end local data = {} - for l in lines do + for l in lines do local c = string.sub(l, 1, 1) if c ~= '#' and c ~= '.' then local key, value = socket.skip(2, string.find(l, "(.-)=(.*)")) @@ -26,7 +26,7 @@ function parse(body) data[key] = value end end - return data, code, message + return data, code, message end local host = socket.dns.gethostname() @@ -34,13 +34,13 @@ local query = "%s?cmd=cddb+read+%s+%s&hello=LuaSocket+%s+LuaSocket+2.0&proto=6" local url = string.format(query, server, arg[1], arg[2], host) local body, headers, code = http.get(url) -if code == 200 then +if code == 200 then local data, code, error = parse(body) - if not data then + if not data then print(error or code) else - for i,v in pairs(data) do - io.write(i, ': ', v, '\n') + for i,v in pairs(data) do + io.write(i, ': ', v, '\n') end end else print(error) end diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua index d4449e5..8d39ed9 100644 --- a/samples/echosrvr.lua +++ b/samples/echosrvr.lua @@ -20,10 +20,10 @@ assert(ip, port) print("Waiting packets on " .. ip .. ":" .. port .. "...") while 1 do dgram, ip, port = udp:receivefrom() - if dgram then + if dgram then print("Echoing '" .. dgram .. "' to " .. ip .. ":" .. port) udp:sendto(dgram, ip, port) - else - print(ip) + else + print(ip) end end diff --git a/samples/lpr.lua b/samples/lpr.lua index 5ab4d69..2b059b1 100644 --- a/samples/lpr.lua +++ b/samples/lpr.lua @@ -36,7 +36,8 @@ do return usage() end if arg[1] ~= "query" then - r,e=lp.send(arg[1],opt) + opt.file = arg[1] + r,e=lp.send(opt) io.stdout:write(tostring(r or e),'\n') else r,e=lp.query(opt) diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua index e3dd517..dd2c6f8 100644 --- a/samples/tinyirc.lua +++ b/samples/tinyirc.lua @@ -62,24 +62,24 @@ while 1 do if input == server1 or input == server2 then io.write("Waiting for clients\n") local new = input:accept() - if new then + if new then new:settimeout(1) io.write("Inserting client in set\n") - set:insert(new) + set:insert(new) end -- it is a client socket else local line, error = input:receive() - if error then + if error then input:close() io.write("Removing client from set\n") - set:remove(input) + set:remove(input) else io.write("Broadcasting line '", line, "'\n") writable, error = socket.skip(1, socket.select(nil, set, 1)) if not error then for __, output in ipairs(writable) do - if output ~= input then + if output ~= input then output:send(line .. "\n") end end -- cgit v1.2.3-55-g6feb