diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2011-05-25 20:57:22 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2011-05-25 20:57:22 +0000 |
commit | 3a8ba90dfb0c2eb224f317dd692ede426691e72a (patch) | |
tree | fe1cc5379a2e0e031663fe9c15d908653844bc73 /etc/dict.lua | |
parent | bce60be30fe8e9c1b0eb33128c23c93d7bca5303 (diff) | |
download | luasocket-3a8ba90dfb0c2eb224f317dd692ede426691e72a.tar.gz luasocket-3a8ba90dfb0c2eb224f317dd692ede426691e72a.tar.bz2 luasocket-3a8ba90dfb0c2eb224f317dd692ede426691e72a.zip |
Saving before big changes to support IPv6.
Diffstat (limited to 'etc/dict.lua')
-rw-r--r-- | etc/dict.lua | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/etc/dict.lua b/etc/dict.lua index 5c85aae..6eb3210 100644 --- a/etc/dict.lua +++ b/etc/dict.lua | |||
@@ -44,48 +44,48 @@ function metat.__index:check(ok) | |||
44 | end | 44 | end |
45 | 45 | ||
46 | function metat.__index:getdef() | 46 | function metat.__index:getdef() |
47 | local line = socket.try(self.tp:receive()) | 47 | local line = socket.try(self.tp:receive()) |
48 | local def = {} | 48 | local def = {} |
49 | while line ~= "." do | 49 | while line ~= "." do |
50 | table.insert(def, line) | 50 | table.insert(def, line) |
51 | line = socket.try(self.tp:receive()) | 51 | line = socket.try(self.tp:receive()) |
52 | end | 52 | end |
53 | return table.concat(def, "\n") | 53 | return table.concat(def, "\n") |
54 | end | 54 | end |
55 | 55 | ||
56 | function metat.__index:define(database, word) | 56 | function metat.__index:define(database, word) |
57 | database = database or "!" | 57 | database = database or "!" |
58 | socket.try(self.tp:command("DEFINE", database .. " " .. word)) | 58 | socket.try(self.tp:command("DEFINE", database .. " " .. word)) |
59 | local code, count = self:check(150) | 59 | local code, count = self:check(150) |
60 | local defs = {} | 60 | local defs = {} |
61 | for i = 1, count do | 61 | for i = 1, count do |
62 | self:check(151) | 62 | self:check(151) |
63 | table.insert(defs, self:getdef()) | 63 | table.insert(defs, self:getdef()) |
64 | end | 64 | end |
65 | self:check(250) | 65 | self:check(250) |
66 | return defs | 66 | return defs |
67 | end | 67 | end |
68 | 68 | ||
69 | function metat.__index:match(database, strat, word) | 69 | function metat.__index:match(database, strat, word) |
70 | database = database or "!" | 70 | database = database or "!" |
71 | strat = strat or "." | 71 | strat = strat or "." |
72 | socket.try(self.tp:command("MATCH", database .." ".. strat .." ".. word)) | 72 | socket.try(self.tp:command("MATCH", database .." ".. strat .." ".. word)) |
73 | self:check(152) | 73 | self:check(152) |
74 | local mat = {} | 74 | local mat = {} |
75 | local line = socket.try(self.tp:receive()) | 75 | local line = socket.try(self.tp:receive()) |
76 | while line ~= '.' do | 76 | while line ~= '.' do |
77 | database, word = socket.skip(2, string.find(line, "(%S+) (.*)")) | 77 | database, word = socket.skip(2, string.find(line, "(%S+) (.*)")) |
78 | if not mat[database] then mat[database] = {} end | 78 | if not mat[database] then mat[database] = {} end |
79 | table.insert(mat[database], word) | 79 | table.insert(mat[database], word) |
80 | line = socket.try(self.tp:receive()) | 80 | line = socket.try(self.tp:receive()) |
81 | end | 81 | end |
82 | self:check(250) | 82 | self:check(250) |
83 | return mat | 83 | return mat |
84 | end | 84 | end |
85 | 85 | ||
86 | function metat.__index:quit() | 86 | function metat.__index:quit() |
87 | self.tp:command("QUIT") | 87 | self.tp:command("QUIT") |
88 | return self:check(221) | 88 | return self:check(221) |
89 | end | 89 | end |
90 | 90 | ||
91 | function metat.__index:close() | 91 | function metat.__index:close() |