mirror of
https://github.com/ShadowKatStudios/OC-Minitel.git
synced 2024-11-23 10:38:05 +11:00
implemented the rev1 FRequest protocol in the bundled programs
This commit is contained in:
parent
884c868d9b
commit
3d45735361
@ -20,29 +20,44 @@ function start()
|
|||||||
buffer=s:read(1024)
|
buffer=s:read(1024)
|
||||||
local nl = buffer:find("\n")
|
local nl = buffer:find("\n")
|
||||||
if nl then
|
if nl then
|
||||||
local path=prefix .. "/" .. buffer:sub(1,nl-1)
|
local rt = buffer:sub(1,1)
|
||||||
|
local path=prefix .. "/" .. buffer:sub(2,nl-1)
|
||||||
dprint(path)
|
dprint(path)
|
||||||
|
if path:find("%.%./") then
|
||||||
|
s:write("f to pay respects")
|
||||||
|
s:close()
|
||||||
|
return
|
||||||
|
end
|
||||||
if fs.exists(path) then
|
if fs.exists(path) then
|
||||||
if fs.isDirectory(path) then
|
if rt == "t" then
|
||||||
if fs.exists(path.."/index") then
|
if fs.isDirectory(path) then
|
||||||
|
s:write("d")
|
||||||
|
if fs.exists(path.."/index") then
|
||||||
|
local f=io.open(path.."/index","rb")
|
||||||
|
s:write(f:read("*a"))
|
||||||
|
f:close()
|
||||||
|
end
|
||||||
|
local dbuffer = ""
|
||||||
|
for f in fs.list(path) do
|
||||||
|
dbuffer = dbuffer..f.."\n"
|
||||||
|
dprint(f)
|
||||||
|
end
|
||||||
|
s:write(dbuffer)
|
||||||
|
s:close()
|
||||||
|
else
|
||||||
|
s:write("y")
|
||||||
|
local f = io.open(path,"rb")
|
||||||
s:write(f:read("*a"))
|
s:write(f:read("*a"))
|
||||||
|
f:close()
|
||||||
|
s:close()
|
||||||
end
|
end
|
||||||
local dbuffer = ""
|
|
||||||
for f in fs.list(path) do
|
|
||||||
dbuffer = dbuffer..f.."\n"
|
|
||||||
dprint(f)
|
|
||||||
end
|
|
||||||
s:write(dbuffer)
|
|
||||||
s:close()
|
|
||||||
else
|
else
|
||||||
local f = io.open(path,"rb")
|
s:write(tostring(fs.size(path)))
|
||||||
s:write(f:read("*a"))
|
|
||||||
f:close()
|
|
||||||
s:close()
|
s:close()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
dprint("404")
|
dprint("404")
|
||||||
s:write("file not found")
|
s:write("not found")
|
||||||
s:close()
|
s:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -12,7 +12,19 @@ if sep then
|
|||||||
end
|
end
|
||||||
|
|
||||||
local socket = net.open(host,port)
|
local socket = net.open(host,port)
|
||||||
socket:write(path.."\n")
|
socket:write("t"..path.."\n")
|
||||||
|
local c = socket:read(1)
|
||||||
|
repeat
|
||||||
|
c = socket:read(1)
|
||||||
|
os.sleep(0.5)
|
||||||
|
until c ~= ""
|
||||||
|
if c == "n" then
|
||||||
|
print(path..": Not found.")
|
||||||
|
elseif c == "f" then
|
||||||
|
print("Failure: ")
|
||||||
|
elseif c == "d" then
|
||||||
|
print("Directory listing for "..path)
|
||||||
|
end
|
||||||
repeat
|
repeat
|
||||||
l = socket:read(1024)
|
l = socket:read(1024)
|
||||||
io.write(l)
|
io.write(l)
|
||||||
|
Loading…
Reference in New Issue
Block a user