diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-11-27 07:58:04 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-11-27 07:58:04 +0000 |
commit | 7c97e8e40aaa665226fb54449773dc3134e755b2 (patch) | |
tree | 47888d4c924fc24bf3b355bf58120ea3cdc74bc4 /etc/dict.lua | |
parent | eb0fc857ddea6f084d338589e2a33d3e7d4eade6 (diff) | |
download | luasocket-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.lua | 16 |
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 | ----------------------------------------------------------------------------- |
11 | local base = require("base") | ||
12 | local string = require("string") | ||
13 | local table = require("table") | ||
11 | local socket = require("socket") | 14 | local socket = require("socket") |
12 | local url = require("socket.url") | 15 | local url = require("socket.url") |
13 | local tp = require("socket.tp") | 16 | local tp = require("socket.tp") |
14 | 17 | ||
15 | module("socket.dict") | 18 | local dict = module("socket.dict") |
16 | 19 | ||
17 | ----------------------------------------------------------------------------- | 20 | ----------------------------------------------------------------------------- |
18 | -- Globals | 21 | -- Globals |
@@ -28,7 +31,7 @@ local metat = { __index = {} } | |||
28 | 31 | ||
29 | function open(host, port) | 32 | function 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) |
32 | end | 35 | end |
33 | 36 | ||
34 | function metat.__index:greet() | 37 | function metat.__index:greet() |
@@ -37,7 +40,8 @@ end | |||
37 | 40 | ||
38 | function metat.__index:check(ok) | 41 | function 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*)"))) | ||
41 | end | 45 | end |
42 | 46 | ||
43 | function metat.__index:getdef() | 47 | function 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 |
121 | end | 125 | end |
122 | 126 | ||
@@ -143,6 +147,8 @@ local function sget(u) | |||
143 | end | 147 | end |
144 | 148 | ||
145 | get = socket.protect(function(gett) | 149 | get = 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 |
148 | end) | 152 | end) |
153 | |||
154 | base.setmetatable(dict, nil) | ||