SMBc.lua

verze = "21.0530.R1"
local idPC = os.getComputerID()
local tArgs = { ... }
modem = peripheral.wrap("top")
modem.open(idPC)

function prijmout ()
    local _, side, freq, rfreq, message = os.pullEvent('modem_message')

    if (rfreq == 992) then
		if message then
		prijmout()
		else
		print(message)
		local file = fs.open(tArgs[4],"w")
		file.write("fail-false")
		file.close()
		end
    end
	
	if (rfreq == 994) then
		local file = fs.open(tArgs[4],"w")
		file.write(message)
		file.close()
    end
end

function vyhodnotit()
	if fs.exists(tArgs[4]) then
		local data = fs.open(tArgs[4], "r")
		soubor = data.readLine()
		data.close()
	end
end

function poslat(filePath)
	local data = fs.open(filePath, "r")
		obsah = data.readAll()
		data.close()
		modem.transmit(tonumber(tArgs[1]),994,obsah)
end

if #tArgs > 0 then
	modem.transmit(tonumber(tArgs[1]),990,idPC)
		if (tArgs[2] == "copy") or (tArgs[2] == "cut") then
		modem.transmit(tonumber(tArgs[1]),991,tArgs[3])
		modem.transmit(tonumber(tArgs[1]),993,tArgs[2])
		prijmout()
		elseif (tArgs[2] == "signature") or (tArgs[2] == "delete") then
		modem.transmit(tonumber(tArgs[1]),991,tArgs[3])
		modem.transmit(tonumber(tArgs[1]),993,tArgs[2])
		if (tArgs[2] == "signature") then
			tArgs[4] = "/C/system/RAM/struktura.tmp"
			if fs.exists(tArgs[4]) then fs.delete(tArgs[4]) end
			prijmout()
			vyhodnotit()
		end
		elseif (tArgs[2] == "paste") then
		modem.transmit(tonumber(tArgs[1]),991,tArgs[4])
		poslat(tArgs[3])
		modem.transmit(tonumber(tArgs[1]),993,tArgs[2])
		print("Soubor odeslan!")
		end
	else
	print("smbc server prikaz cesta kam")
	--     0      1     2       3    4
end