aboutsummaryrefslogtreecommitdiff
path: root/etc/dict.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-11-27 07:58:04 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-11-27 07:58:04 +0000
commit7c97e8e40aaa665226fb54449773dc3134e755b2 (patch)
tree47888d4c924fc24bf3b355bf58120ea3cdc74bc4 /etc/dict.lua
parenteb0fc857ddea6f084d338589e2a33d3e7d4eade6 (diff)
downloadluasocket-7c97e8e40aaa665226fb54449773dc3134e755b2.tar.gz
luasocket-7c97e8e40aaa665226fb54449773dc3134e755b2.tar.bz2
luasocket-7c97e8e40aaa665226fb54449773dc3134e755b2.zip
Almost ready for beta3
Diffstat (limited to 'etc/dict.lua')
-rw-r--r--etc/dict.lua16
1 files changed, 11 insertions, 5 deletions
diff --git a/etc/dict.lua b/etc/dict.lua
index 8c197f5..716b8db 100644
--- a/etc/dict.lua
+++ b/etc/dict.lua
@@ -8,11 +8,14 @@
8----------------------------------------------------------------------------- 8-----------------------------------------------------------------------------
9-- Load required modules 9-- Load required modules
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11local base = require("base")
12local string = require("string")
13local table = require("table")
11local socket = require("socket") 14local socket = require("socket")
12local url = require("socket.url") 15local url = require("socket.url")
13local tp = require("socket.tp") 16local tp = require("socket.tp")
14 17
15module("socket.dict") 18local dict = module("socket.dict")
16 19
17----------------------------------------------------------------------------- 20-----------------------------------------------------------------------------
18-- Globals 21-- Globals
@@ -28,7 +31,7 @@ local metat = { __index = {} }
28 31
29function open(host, port) 32function open(host, port)
30 local tp = socket.try(tp.connect(host or HOST, port or PORT, TIMEOUT)) 33 local tp = socket.try(tp.connect(host or HOST, port or PORT, TIMEOUT))
31 return setmetatable({tp = tp}, metat) 34 return base.setmetatable({tp = tp}, metat)
32end 35end
33 36
34function metat.__index:greet() 37function metat.__index:greet()
@@ -37,7 +40,8 @@ end
37 40
38function metat.__index:check(ok) 41function metat.__index:check(ok)
39 local code, status = socket.try(self.tp:check(ok)) 42 local code, status = socket.try(self.tp:check(ok))
40 return code, tonumber(socket.skip(2, string.find(status, "^%d%d%d (%d*)"))) 43 return code,
44 base.tonumber(socket.skip(2, string.find(status, "^%d%d%d (%d*)")))
41end 45end
42 46
43function metat.__index:getdef() 47function metat.__index:getdef()
@@ -116,7 +120,7 @@ local function parse(u)
116 if cmd == "m" then 120 if cmd == "m" then
117 arg = string.gsub(arg, "^:([^:]*)", function(f) t.strat = there(f) end) 121 arg = string.gsub(arg, "^:([^:]*)", function(f) t.strat = there(f) end)
118 end 122 end
119 string.gsub(arg, ":([^:]*)$", function(f) t.n = tonumber(f) end) 123 string.gsub(arg, ":([^:]*)$", function(f) t.n = base.tonumber(f) end)
120 return t 124 return t
121end 125end
122 126
@@ -143,6 +147,8 @@ local function sget(u)
143end 147end
144 148
145get = socket.protect(function(gett) 149get = socket.protect(function(gett)
146 if type(gett) == "string" then return sget(gett) 150 if base.type(gett) == "string" then return sget(gett)
147 else return tget(gett) end 151 else return tget(gett) end
148end) 152end)
153
154base.setmetatable(dict, nil)