aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2000-12-29 22:15:09 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2000-12-29 22:15:09 +0000
commit17c4d1c30544f0ed638879835f179ada96249868 (patch)
tree46ca8042ba8fda147f56af61e26ec2ceec41f614 /etc
parent6f9d15b66027cef58441549f8ac0603ca42da0ac (diff)
downloadluasocket-17c4d1c30544f0ed638879835f179ada96249868.tar.gz
luasocket-17c4d1c30544f0ed638879835f179ada96249868.tar.bz2
luasocket-17c4d1c30544f0ed638879835f179ada96249868.zip
Initial revision
Diffstat (limited to 'etc')
-rw-r--r--etc/dict.lua39
1 files changed, 39 insertions, 0 deletions
diff --git a/etc/dict.lua b/etc/dict.lua
new file mode 100644
index 0000000..683cb45
--- /dev/null
+++ b/etc/dict.lua
@@ -0,0 +1,39 @@
1-- dict.lua
2-- simple client for DICT protocol (see http://www.dict.org/)
3-- shows definitions for each word from stdin. uses only "wn" dictionary.
4-- if a word is "=", then the rest of the line is sent verbatim as a protocol
5-- command to the server.
6
7if verbose then verbose=write else verbose=function()end end
8
9verbose(">>> connecting to server\n")
10local s,e=connect("dict.org",2628)
11assert(s,e)
12verbose(">>> connected\n")
13
14while 1 do
15 local w=read"*w"
16 if w==nil then break end
17 if w=="=" then
18 w=read"*l"
19 verbose(">>>",w,"\n")
20 send(s,w,"\r\n")
21 else
22 verbose(">>> looking up `",w,"'\n")
23 send(s,"DEFINE wn ",w,"\r\n")
24 end
25 while 1 do
26 local l=receive(s)
27 if l==nil then break end
28 if strfind(l,"^[0-9]") then
29 write("<<< ",l,"\n")
30 else
31 write(l,"\n")
32 end
33 if strfind(l,"^250") or strfind(l,"^[45]") then break end
34 end
35end
36
37send(s,"QUIT\r\n")
38verbose("<<< ",receive(s),"\n")
39close(s)