diff options
Diffstat (limited to 'src/modules/debug_shell.lua')
-rw-r--r-- | src/modules/debug_shell.lua | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/modules/debug_shell.lua b/src/modules/debug_shell.lua index a629d3b..9c3b605 100644 --- a/src/modules/debug_shell.lua +++ b/src/modules/debug_shell.lua @@ -1,15 +1,15 @@ -- -- gcsd -- --- gcsd the generic command sequencer daemon can be used to serialize +-- gcsd the generic command sequencer daemon can be used to serialize -- commands sent over various paralell communication channels to a -- single command output. It can be seen as a multiplexer for any -- kind of communication between a single resource and various clients -- which want to submit commands to it or query information from it. --- gcsd is written in C and Lua. The goal is to provide an easy to +-- gcsd is written in C and Lua. The goal is to provide an easy to -- understand high level API based on Lua which can be used to -- implement the business logic of the so formed multiplexer daemon. --- +-- -- -- Copyright (C) 2009-2010 Markus Grueneis <gimpf@spreadspace.org> -- Christian Pointner <equinox@spreadspace.org> @@ -53,7 +53,7 @@ function debug_shell:new(config, runtype) local lst, err = tcp.server(config.addr, config.port, config.resolv_type) if(not lst) then return nil - end + end inst.listeners = lst for _, l in ipairs(inst.listeners) do @@ -71,7 +71,7 @@ function debug_shell:new(config, runtype) client_handle.client_instance = nil client_handle.in_buffer = "" client_handle.out_buffer = "" - function client_handle:read() + function client_handle:read() -- TODO: which size should we request?? local buffer, err = tcp.recv(self.fd, 100) if(buffer == nil) then @@ -82,7 +82,7 @@ function debug_shell:new(config, runtype) log.printf(log.INFO, inst.name .. ": connection closed") return defines.KILL_CLIENT end - self.in_buffer = self.in_buffer .. buffer + self.in_buffer = self.in_buffer .. buffer return debug_shell:parse_cmd(self) end function client_handle:write() @@ -121,7 +121,7 @@ function debug_shell:new(config, runtype) end function l:write() return defines.OK end end - + function inst:cleanup() client_list:unregister_by_module(self) for _, l in ipairs(self.listeners) do @@ -153,13 +153,13 @@ function debug_shell:parse_cmd(handle) break end until (not had_match or ret ~= defines.OK) - + handle.in_buffer = string.sub(handle.in_buffer, init + 1) return ret end -function debug_shell:exec_cmd(handle, buffer) +function debug_shell:exec_cmd(handle, buffer) local client_name = handle.client_instance.name log.printf(log.DEBUG, client_name .. ": received string: '%s'", buffer) @@ -167,7 +167,7 @@ function debug_shell:exec_cmd(handle, buffer) local luacode = string.match(buffer, "^!(.*)$"); if(luacode and luacode ~= "") then local chunk = loadstring(luacode) - if(chunk) then + if(chunk) then log.printf(log.DEBUG, client_name .. ": calling lua command: '%s'", luacode) local results = { pcall(chunk) } if(results[1]) then @@ -184,7 +184,7 @@ function debug_shell:exec_cmd(handle, buffer) end else local cmd, sep, param = string.match(buffer, "^(%w+)(.?)(.*)$"); - + if(cmd == 'quit') then if(sep and sep ~= "") then handle.out_buffer = handle.out_buffer .. "unknown command\n" end log.printf(log.INFO, client_name .. ": quitting debug session") @@ -215,15 +215,15 @@ function debug_shell:exec_cmd(handle, buffer) else handle.out_buffer = handle.out_buffer .. "pong\n" end elseif(cmd == 'cmd') then if(not param or param == '') then handle.out_buffer = handle.out_buffer .. "Error: please specify a command\n" - else + else handle.out_buffer = handle.out_buffer .. "enqueing command: " .. param .. "\n" command_queue:enqueue(param, "ok\n", 2500) end - else + else handle.out_buffer = handle.out_buffer .. "unknown command\n" end end - + return ret end |