From c3220ddbebfea652a953f19757a4877d4e931b6f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 26 Dec 2010 16:51:35 +0000 Subject: removed defines.lua, initializing defines from c api git-svn-id: https://svn.spreadspace.org/gcsd/trunk@74 ac14a137-c7f1-4531-abe0-07747231d213 --- TODO | 1 + src/command_queue.lua | 2 -- src/defines.lua | 46 --------------------------------------------- src/dispatch_tables.lua | 1 - src/gcsd.c | 39 +++++++++++++++++++++++++++++++++++++- src/main_loop.lua | 2 -- src/module_list.lua | 2 -- src/modules/debug_shell.lua | 1 - src/modules/dummy.lua | 2 -- src/modules/exec.lua | 2 -- src/modules/stdio.lua | 2 -- src/modules/stdout.lua | 2 -- 12 files changed, 39 insertions(+), 63 deletions(-) delete mode 100644 src/defines.lua diff --git a/TODO b/TODO index 200040c..d40a11b 100644 --- a/TODO +++ b/TODO @@ -10,3 +10,4 @@ - udp - unix - inotify + * exec module, add support for parameters \ No newline at end of file diff --git a/src/command_queue.lua b/src/command_queue.lua index c91f9a7..2c8b10d 100644 --- a/src/command_queue.lua +++ b/src/command_queue.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - command_queue = {} command_queue.commands = {} diff --git a/src/defines.lua b/src/defines.lua deleted file mode 100644 index 1639934..0000000 --- a/src/defines.lua +++ /dev/null @@ -1,46 +0,0 @@ --- --- gcsd --- --- 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 --- 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 --- Christian Pointner --- --- This file is part of gcsd. --- --- gcsd is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- any later version. --- --- gcsd is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with gcsd. If not, see . --- - -local defines = {} - -defines.OK = 0 -defines.KILL_CLIENT = 1 -defines.KILL_MODULE = 2 -defines.KILL_MODULE_CLASS = 3 -defines.KILL_DAEMON = 4 - -defines.IN_MODULE = 1 -defines.OUT_MODULE = 2 -defines.INOUT_MODULE = 3 -defines.MISC_MODULE = 4 - -return defines diff --git a/src/dispatch_tables.lua b/src/dispatch_tables.lua index 768e33f..1f7b5e5 100644 --- a/src/dispatch_tables.lua +++ b/src/dispatch_tables.lua @@ -33,7 +33,6 @@ dispatch_tables = {} function dispatch_tables:load_handler_tables_file(filename) - local defines = require('defines') if (type(filename) ~= "nil") then if (type(filename) ~= "string") then log.printf(log.ERROR, "filename must be of type 'string' and denote a valid path") diff --git a/src/gcsd.c b/src/gcsd.c index 4fedaf3..c79ed51 100644 --- a/src/gcsd.c +++ b/src/gcsd.c @@ -71,6 +71,43 @@ static const luaL_Reg gcsd_lualibs[] = { {NULL, NULL} }; +int init_defines(lua_State *L) +{ + lua_newtable(L); + + lua_pushliteral(L, "OK"); + lua_pushinteger(L, 0); + lua_settable(L, -3); + lua_pushliteral(L, "KILL_CLIENT"); + lua_pushinteger(L, 1); + lua_settable(L, -3); + lua_pushliteral(L, "KILL_MODULE"); + lua_pushinteger(L, 2); + lua_settable(L, -3); + lua_pushliteral(L, "KILL_MODULE_CLASS"); + lua_pushinteger(L, 3); + lua_settable(L, -3); + lua_pushliteral(L, "KILL_DAEMON"); + lua_pushinteger(L, 4); + lua_settable(L, -3); + + lua_pushliteral(L, "IN_MODULE"); + lua_pushinteger(L, 1); + lua_settable(L, -3); + lua_pushliteral(L, "OUT_MODULE"); + lua_pushinteger(L, 2); + lua_settable(L, -3); + lua_pushliteral(L, "INOUT_MODULE"); + lua_pushinteger(L, 3); + lua_settable(L, -3); + lua_pushliteral(L, "MISC_MODULE"); + lua_pushinteger(L, 4); + lua_settable(L, -3); + + lua_setglobal(L, "defines"); + return 0; +} + int init_main_loop(lua_State *L) { const luaL_Reg *lib = gcsd_lualibs; @@ -102,7 +139,7 @@ int init_main_loop(lua_State *L) return -1; } - return 0; + return init_defines(L); } int call_main_loop(lua_State* L, options_t* opt) diff --git a/src/main_loop.lua b/src/main_loop.lua index ed719ad..f1712d9 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - function get_readables() local readables = {} for _, module in ipairs(module_list.inputs) do diff --git a/src/module_list.lua b/src/module_list.lua index 706c9c0..053d9db 100644 --- a/src/module_list.lua +++ b/src/module_list.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - module_list = {} module_list.classes = {} diff --git a/src/modules/debug_shell.lua b/src/modules/debug_shell.lua index a0d187e..318c539 100644 --- a/src/modules/debug_shell.lua +++ b/src/modules/debug_shell.lua @@ -31,7 +31,6 @@ -- local socket = require("socket") -local defines = require("defines") -- debug shell module class local debug_shell = {} diff --git a/src/modules/dummy.lua b/src/modules/dummy.lua index e8d534e..78cd6c2 100644 --- a/src/modules/dummy.lua +++ b/src/modules/dummy.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - -- dummy module class local dummy = {} dummy.properties = { type=defines.INOUT_MODULE, name="dummy", max_instances=-1 } diff --git a/src/modules/exec.lua b/src/modules/exec.lua index a10503f..fb2a328 100644 --- a/src/modules/exec.lua +++ b/src/modules/exec.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - -- exec module class local exec = {} exec.properties = { type=defines.INOUT_MODULE, name="exec", max_instances=-1 } diff --git a/src/modules/stdio.lua b/src/modules/stdio.lua index 74795c1..cf011ef 100644 --- a/src/modules/stdio.lua +++ b/src/modules/stdio.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - -- stdio module class local stdio = {} stdio.properties = { type=defines.INOUT_MODULE, name="stdio", max_instances=1 } diff --git a/src/modules/stdout.lua b/src/modules/stdout.lua index b407f80..77ae029 100644 --- a/src/modules/stdout.lua +++ b/src/modules/stdout.lua @@ -30,8 +30,6 @@ -- along with gcsd. If not, see . -- -local defines = require("defines") - -- stdout module class local stdout = {} stdout.properties = { type=defines.OUT_MODULE, name="stdout", max_instances=1 } -- cgit v1.2.3