diff options
author | Christian Pointner <equinox@spreadspace.org> | 2010-12-29 03:08:07 +0000 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2010-12-29 03:08:07 +0000 |
commit | 6a7cbe87fa611e290741c47267b3900707021e5c (patch) | |
tree | ed1fbd244a5a742ebd43f4a20fb1d58df4a3d9d4 /src | |
parent | debug shell not using lua sockets any more (diff) |
removed trailing whitespaces
git-svn-id: https://svn.spreadspace.org/gcsd/trunk@87 ac14a137-c7f1-4531-abe0-07747231d213
Diffstat (limited to 'src')
40 files changed, 234 insertions, 234 deletions
diff --git a/src/Makefile b/src/Makefile index 9ba9c9c..7cb569e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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> diff --git a/src/client_list.lua b/src/client_list.lua index cb4ed8d..533b4f5 100644 --- a/src/client_list.lua +++ b/src/client_list.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> diff --git a/src/command_queue.lua b/src/command_queue.lua index 041e63a..7f95d9b 100644 --- a/src/command_queue.lua +++ b/src/command_queue.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> @@ -76,7 +76,7 @@ end function command_queue:command_sent() if(self.current == nil) then return end - + self.current.sent = true if(self.current.timeout) then self.current.expiration_time = timer.now() + self.current.timeout @@ -93,7 +93,7 @@ end function command_queue:check_timeout() if(self.current == nil or not self.current.sent) then return end if(not self.current.expiration_time) then return end - + if(timer.cmp(timer.now(), self.current.expiration_time) == 1) then log.printf(log.NOTICE, "command timed out") self:command_completed() @@ -102,7 +102,7 @@ end function command_queue:command_completed() if(self.current == nil) then return end - + table.remove(self.commands, 1) self.current = nil end diff --git a/src/command_table.lua b/src/command_table.lua index e3e6b42..e747729 100644 --- a/src/command_table.lua +++ b/src/command_table.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> @@ -60,6 +60,6 @@ function command_table:dispatch(command_buffer) end end until (not had_match) - + return string.sub(command_buffer, init + 1) end diff --git a/src/configure b/src/configure index 9b834ab..e0a2411 100755 --- a/src/configure +++ b/src/configure @@ -1,35 +1,35 @@ #!/bin/sh -# +# # 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> -# +# # 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 <http://www.gnu.org/licenses/>. -# +# TARGET=`uname -s` EBUILD_COMPAT=0 @@ -121,7 +121,7 @@ fi rm -f version.h rm -f include.mk -case $TARGET in +case $TARGET in Linux) LDFLAGS=$LDFLAGS' -ldl' ;; @@ -234,7 +234,7 @@ fi cat >> include.mk <<EOF # this file was created automatically -# do not edit this file directly +# do not edit this file directly # use ./configure instead TARGET := '$TARGET' @@ -282,7 +282,7 @@ HOSTNAME=`hostname` DATE=`date +"%d.%m.%Y %H:%M:%S %Z"` cat > config.h <<EOF -/* +/* * gcsd version info * * this file was created automatically diff --git a/src/daemon.h b/src/daemon.h index 95ed3e8..1b8e7d6 100644 --- a/src/daemon.h +++ b/src/daemon.h @@ -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> diff --git a/src/datatypes.h b/src/datatypes.h index 43bcd7e..dca12b1 100644 --- a/src/datatypes.h +++ b/src/datatypes.h @@ -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> diff --git a/src/dispatch_tables.lua b/src/dispatch_tables.lua index 1f7b5e5..49c09d9 100644 --- a/src/dispatch_tables.lua +++ b/src/dispatch_tables.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> @@ -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> @@ -192,7 +192,7 @@ int main_loop(options_t* opt) int ret = init_main_loop(L); if(!ret) ret = call_main_loop(L, opt); - + lua_close(L); return ret; } @@ -214,7 +214,7 @@ int main(int argc, char* argv[]) options_print_version(); } - if(ret != -2 && ret != -3) + if(ret != -2 && ret != -3) options_print_usage(); if(ret == -1 || ret == -3) @@ -234,7 +234,7 @@ int main(int argc, char* argv[]) case -4: fprintf(stderr, "this log target is only allowed once: '%s', exitting\n", tmp->string_); break; default: fprintf(stderr, "syntax error near: '%s', exitting\n", tmp->string_); break; } - + options_clear(&opt); log_close(); exit(ret); @@ -275,7 +275,7 @@ int main(int argc, char* argv[]) options_clear(&opt); log_close(); exit(-1); - } + } if(opt.daemonize_) { pid_t oldpid = getpid(); diff --git a/src/l_log.c b/src/l_log.c index ea9d1a3..7fb4e79 100644 --- a/src/l_log.c +++ b/src/l_log.c @@ -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> @@ -64,7 +64,7 @@ static int l_log_add_target(lua_State *L) default: lua_pushstring(L, "syntax error"); break; } return 2; - } + } lua_pushboolean(L, 1); return 1; @@ -84,22 +84,22 @@ static int l_log_printf(lua_State *L) lua_remove(L, -1); lua_call(L, numargs - 1, 1); } - + log_prio_t prio = luaL_checkint(L,1); log_printf(prio, "%s", luaL_checkstring(L, 2)); return 0; } static const struct luaL_reg log_funcs [] = { - { "init", l_log_init }, - { "close", l_log_close }, + { "init", l_log_init }, + { "close", l_log_close }, { "add_target", l_log_add_target }, { "printf", l_log_printf }, { NULL, NULL } }; -LUALIB_API int luaopen_log(lua_State *L) +LUALIB_API int luaopen_log(lua_State *L) { luaL_register(L, LUA_LOGLIBNAME, log_funcs); lua_pushliteral(L, "ERROR"); diff --git a/src/l_log.h b/src/l_log.h index c80614a..3f65f21 100644 --- a/src/l_log.h +++ b/src/l_log.h @@ -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> diff --git a/src/l_rawio.c b/src/l_rawio.c index 779d6ae..3ba2851 100644 --- a/src/l_rawio.c +++ b/src/l_rawio.c @@ -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 @@ static int l_rawio_open(lua_State *L) if(strstr(mode_str, "O_RDONLY")) mode |= O_RDONLY; if(strstr(mode_str, "O_WRONLY")) mode |= O_WRONLY; - if(strstr(mode_str, "O_RDWR")) mode |= O_RDWR; + if(strstr(mode_str, "O_RDWR")) mode |= O_RDWR; int fd = open(filename, mode); lua_pushinteger(L, fd); @@ -62,7 +62,7 @@ static int l_rawio_open(lua_State *L) static int l_rawio_setnonblock(lua_State *L) { - int fd = luaL_checkint(L,1); + int fd = luaL_checkint(L,1); int ret = fcntl(fd, F_SETFL, O_NONBLOCK); if(ret == -1) { @@ -80,9 +80,9 @@ static int l_rawio_write(lua_State *L) int fd = luaL_checkint(L,1); size_t len = 0; const char* data = luaL_checklstring(L, 2, &len); - + int ret = write(fd, data, len); - + if(ret == -1) { lua_pushnil(L); // FIXXXXXME: strerror is not threadsafe!!! @@ -103,9 +103,9 @@ static int l_rawio_read(lua_State *L) lua_pushstring(L, "bad alloc"); return 2; } - + int ret = read(fd, data, len); - + if(ret == -1) { lua_pushnil(L); // FIXXXXXME: strerror is not threadsafe!!! @@ -134,7 +134,7 @@ static const struct luaL_reg rawio_funcs [] = { }; -LUALIB_API int luaopen_rawio(lua_State *L) +LUALIB_API int luaopen_rawio(lua_State *L) { luaL_register(L, LUA_RAWIOLIBNAME, rawio_funcs); return 1; diff --git a/src/l_rawio.h b/src/l_rawio.h index 9fa8713..328dca2 100644 --- a/src/l_rawio.h +++ b/src/l_rawio.h @@ -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> diff --git a/src/l_sig_handler.c b/src/l_sig_handler.c index 01e9662..35d8c14 100644 --- a/src/l_sig_handler.c +++ b/src/l_sig_handler.c @@ -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> @@ -64,14 +64,14 @@ static int l_signal_handle(lua_State *L) } static const struct luaL_reg signal_funcs [] = { - { "init", l_signal_init }, - { "stop", l_signal_stop }, + { "init", l_signal_init }, + { "stop", l_signal_stop }, { "handle", l_signal_handle }, { NULL, NULL } }; -LUALIB_API int luaopen_signal(lua_State *L) +LUALIB_API int luaopen_signal(lua_State *L) { luaL_register(L, LUA_SIGNALLIBNAME, signal_funcs); return 1; diff --git a/src/l_sig_handler.h b/src/l_sig_handler.h index 5730659..e7af745 100644 --- a/src/l_sig_handler.h +++ b/src/l_sig_handler.h @@ -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> diff --git a/src/l_tcp.c b/src/l_tcp.c index c00921e..9418ea5 100644 --- a/src/l_tcp.c +++ b/src/l_tcp.c @@ -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> @@ -70,7 +70,7 @@ static char* tcp_endpoint_to_string(tcp_endpoint_t* e) size_t addrstr_len = 0; char addrstr[INET6_ADDRSTRLEN + 1], portstr[6], *ret; char addrport_sep = ':'; - + switch(e->addr_.ss_family) { case AF_INET: addrport_sep = ':'; break; @@ -152,7 +152,7 @@ static int l_tcp_server(lua_State *L) if(!strcmp(addr, "*") || !strlen(addr)) addr = NULL; const char* port = luaL_checkstring(L, 2); int af = luaL_optint(L, 3, 0); - + struct addrinfo *res = tcp_resolve_endpoint(addr, port, af, 1); if(!res) { lua_pushnil(L); @@ -299,11 +299,11 @@ static int l_tcp_client(lua_State *L) memcpy(se, &source, sizeof(tcp_endpoint_t)); lua_settable(L, -3); } - + lua_pushliteral(L, "fd"); lua_pushinteger(L, fd); lua_settable(L, -3); - + if(connect(fd, (struct sockaddr *)&(remote.addr_), remote.len_)==-1) { if(errno == EINPROGRESS) { lua_pushboolean(L, 0); @@ -316,7 +316,7 @@ static int l_tcp_client(lua_State *L) lua_pushstring(L, "connect() failed"); return 2; } - + lua_pushboolean(L, 1); return 2; } @@ -353,9 +353,9 @@ static int l_tcp_recv(lua_State *L) lua_pushstring(L, "bad alloc"); return 2; } - + int ret = recv(fd, data, len, 0); - + if(ret == -1) { lua_pushnil(L); // FIXXXXXME: strerror is not threadsafe!!! @@ -373,9 +373,9 @@ static int l_tcp_send(lua_State *L) int fd = luaL_checkint(L,1); size_t len = 0; const char* data = luaL_checklstring(L, 2, &len); - + int ret = send(fd, data, len, 0); - + if(ret == -1) { lua_pushnil(L); // FIXXXXXME: strerror is not threadsafe!!! @@ -409,7 +409,7 @@ static const struct luaL_reg tcp_funcs [] = { { NULL, NULL } }; -LUALIB_API int luaopen_tcp(lua_State *L) +LUALIB_API int luaopen_tcp(lua_State *L) { luaL_register(L, LUA_TCPLIBNAME, tcp_funcs); return 1; diff --git a/src/l_tcp.h b/src/l_tcp.h index 8e3c78e..e9bf7e5 100644 --- a/src/l_tcp.h +++ b/src/l_tcp.h @@ -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> diff --git a/src/l_timer.c b/src/l_timer.c index f510e22..dfe3135 100644 --- a/src/l_timer.c +++ b/src/l_timer.c @@ -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> @@ -122,7 +122,7 @@ static const struct luaL_reg timer_funcs [] = { { NULL, NULL } }; -LUALIB_API int luaopen_timer(lua_State *L) +LUALIB_API int luaopen_timer(lua_State *L) { luaL_register(L, LUA_TIMERLIBNAME, timer_funcs); return 1; diff --git a/src/l_timer.h b/src/l_timer.h index d814920..bfea670 100644 --- a/src/l_timer.h +++ b/src/l_timer.h @@ -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> diff --git a/src/l_util.c b/src/l_util.c index 93c2aec..3b174b6 100644 --- a/src/l_util.c +++ b/src/l_util.c @@ -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> @@ -112,7 +112,7 @@ static int l_util_select(lua_State *L) fd_set readables, writeables; int max_fd = collect_fds(L, 1, &readables, 0); max_fd = collect_fds(L, 2, &writeables, max_fd); - + struct timeval tv; struct timeval* timeout = NULL; if(ms >= 0) { @@ -164,7 +164,7 @@ static char** table_to_argv(lua_State *L, const char* script, int index) i--; for(; i >= 0; --i) free(my_ptrptr[i]); - + free(my_ptrptr); return NULL; } @@ -193,7 +193,7 @@ static char** table_to_evp(lua_State *L, int index) i--; for(; i >= 0; --i) free(my_ptrptr[i]); - + free(my_ptrptr); return NULL; } @@ -210,7 +210,7 @@ void free_ptrptr(char** ptrptr) int i; for(i = 0; ptrptr[i]; ++i) free(ptrptr[i]); - + free(ptrptr); } @@ -264,7 +264,7 @@ static void prepare_fds(lua_State *L, int *child_stdio, int pipefd) for (fd=getdtablesize();fd>=0;--fd) // close all file descriptors if(fd != pipefd && fd != child_stdio[0] && fd != child_stdio[1] && fd != child_stdio[2]) close(fd); fcntl(pipefd, F_SETFD, FD_CLOEXEC); - + int i, ret; for(i = 0; i<3; ++i) { if(child_stdio[i] >= 0) { @@ -454,7 +454,7 @@ static const struct luaL_reg util_funcs [] = { { NULL, NULL } }; -LUALIB_API int luaopen_util(lua_State *L) +LUALIB_API int luaopen_util(lua_State *L) { luaL_register(L, LUA_UTILLIBNAME, util_funcs); lua_newtable(L); diff --git a/src/l_util.h b/src/l_util.h index 14422b8..931d621 100644 --- a/src/l_util.h +++ b/src/l_util.h @@ -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> @@ -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> @@ -86,7 +86,7 @@ int log_targets_target_exists(log_targets_t* targets, log_target_type_t type) if(tmp->type_ == type) return 1; tmp = tmp->next_; - } + } return 0; } @@ -98,7 +98,7 @@ int log_targets_add(log_targets_t* targets, const char* conf) log_target_t* new_target = NULL; int duplicates_allowed = 0; switch(log_target_parse_type(conf)) { -#ifndef WINVER +#ifndef WINVER case TARGET_SYSLOG: new_target = log_target_syslog_new(); break; #endif case TARGET_FILE: new_target = log_target_file_new(); duplicates_allowed = 1; break; @@ -151,7 +151,7 @@ int log_targets_add(log_targets_t* targets, const char* conf) log_target_t* tmp = targets->first_; while(tmp->next_) tmp = tmp->next_; - + tmp->next_ = new_target; } return 0; @@ -251,7 +251,7 @@ void log_print_hex_dump(log_prio_t prio, const uint8_t* buf, uint32_t len) if(offset < 0) return; uint8_t* ptr = &msg[offset]; - + for(i=0; i < len; i++) { if(((i+1)*3) >= (MSG_LENGTH_MAX - offset)) break; @@ -1,15 +1,15 @@ -/* +Installation/* * 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> diff --git a/src/log_targets.h b/src/log_targets.h index 3a12331..10d3edb 100644 --- a/src/log_targets.h +++ b/src/log_targets.h @@ -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> @@ -39,7 +39,7 @@ static char* get_time_formatted() { char* time_string; time_t t = time(NULL); - if(t < 0) + if(t < 0) time_string = "<time read error>"; else { time_string = ctime(&t); @@ -77,7 +77,7 @@ int log_target_syslog_init(log_target_t* self, const char* conf) { if(!self || (conf && conf[0] == 0)) return -1; - + self->param_ = malloc(sizeof(log_target_syslog_param_t)); if(!self->param_) return -2; @@ -93,7 +93,7 @@ int log_target_syslog_init(log_target_t* self, const char* conf) if(!len) { free(self->param_); return -1; - } + } logname = malloc(len+1); if(logname) { strncpy(logname, conf, len); @@ -114,13 +114,13 @@ int log_target_syslog_init(log_target_t* self, const char* conf) ((log_target_syslog_param_t*)(self->param_))->facility_ = DAEMON; return 0; } - + if(end[1] == 0 || end[1] == ',') { free(logname); free(self->param_); return -1; } - + const char* start = end + 1; end = strchr(start, ','); int i; @@ -155,7 +155,7 @@ void log_target_syslog_log(log_target_t* self, log_prio_t prio, const char* msg) if(!self || !self->param_ || !self->opened_) return; - syslog((prio + 2) | ((log_target_syslog_param_t*)(self->param_))->facility_, "%s", msg); + syslog((prio + 2) | ((log_target_syslog_param_t*)(self->param_))->facility_, "%s", msg); } void log_target_syslog_close(log_target_t* self) @@ -207,7 +207,7 @@ int log_target_file_init(log_target_t* self, const char* conf) { if(!self || (conf && conf[0] == 0)) return -1; - + self->param_ = malloc(sizeof(log_target_file_param_t)); if(!self->param_) return -2; @@ -222,7 +222,7 @@ int log_target_file_init(log_target_t* self, const char* conf) if(!len) { free(self->param_); return -1; - } + } logfilename = malloc(len+1); if(logfilename) { strncpy(logfilename, conf, len); diff --git a/src/main_loop.lua b/src/main_loop.lua index 84afa01..46cb0b1 100644 --- a/src/main_loop.lua +++ b/src/main_loop.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> @@ -112,7 +112,7 @@ function main_loop(opt) local ret = reader:read() if(ret == defines.KILL_DAEMON) then return_value = 2 - break + break elseif(ret == defines.KILL_MODULE_CLASS) then module_list:unregister_by_class(reader.client_instance.module_instance.class) elseif(ret == defines.KILL_MODULE) then @@ -126,7 +126,7 @@ function main_loop(opt) ret = writer:write() if(ret == defines.KILL_DAEMON) then return_value = 2 - break + break elseif(ret == defines.KILL_MODULE_CLASS) then module_list:unregister_by_class(writer.client_instance.module_instance.class) elseif(ret == defines.KILL_MODULE) then diff --git a/src/module_list.lua b/src/module_list.lua index b5766aa..e343cf1 100644 --- a/src/module_list.lua +++ b/src/module_list.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> @@ -37,7 +37,7 @@ local mt = {} function mt.__index(table, key) local value = rawget(table, key) if(value ~= nil) then return value end - + log.printf(log.DEBUG, "load module class: %s", key) local filename = defines.MODULES_PATH .. "/" .. key .. ".lua" @@ -57,7 +57,7 @@ module_list.output = nil function module_list:new_instance(class_name, config, runtype) class = self.classes[class_name] if(class.__num_inst) then - if(class.properties.max_instances >= 1 and + if(class.properties.max_instances >= 1 and class.__num_inst >= class.properties.max_instances) then error("max instances of " .. class_name .. " reached"); end @@ -72,7 +72,7 @@ end function module_list:init(opt) local class, config = self:parse_config(opt.cmd_out) if(not class) then return defines.KILL_DAEMON end - if(self.classes[class].properties.type ~= defines.OUT_MODULE and + if(self.classes[class].properties.type ~= defines.OUT_MODULE and self.classes[class].properties.type ~= defines.INOUT_MODULE) then log.printf(log.ERROR, "module class '%s' cannot be used as output module", class); return defines.KILL_DAEMON @@ -86,7 +86,7 @@ function module_list:init(opt) for idx, input in ipairs(opt.cmd_ins) do local class, config = self:parse_config(input) if(not class) then return defines.KILL_DAEMON end - if(self.classes[class].properties.type ~= defines.IN_MODULE and + if(self.classes[class].properties.type ~= defines.IN_MODULE and self.classes[class].properties.type ~= defines.INOUT_MODULE and self.classes[class].properties.type ~= defines.MISC_MODULE) then log.printf(log.ERROR, "module class '%s' cannot be used as input module", class); @@ -113,7 +113,7 @@ function module_list:parse_config(module_config) for k, v in string.gmatch(config_string .. ",", "([^,=]+)=([^,=]+),") do config[k] = v end - + return class, config end 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 diff --git a/src/modules/dummy.lua b/src/modules/dummy.lua index f8282a8..994de10 100644 --- a/src/modules/dummy.lua +++ b/src/modules/dummy.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> @@ -52,7 +52,7 @@ function dummy:new(config, runtype) handle.client_instance = nil function handle:read() end function handle:write() end - + local client = {} client.module_instance = inst client.name = inst.name .. "#0" diff --git a/src/modules/exec.lua b/src/modules/exec.lua index 46f540e..e6a870c 100644 --- a/src/modules/exec.lua +++ b/src/modules/exec.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> @@ -65,7 +65,7 @@ function exec:new(config, runtype) log.printf(log.ERROR, inst.name .. ": exec failed: %s", error) return nil end - + log.printf(log.NOTICE, inst.name .. ": child spawned with pid %d", child.pid) local in_handle = {} @@ -73,7 +73,7 @@ function exec:new(config, runtype) rawio.setnonblock(in_handle.fd) in_handle.client_instance = nil in_handle.in_buffer = "" - function in_handle:read() + function in_handle:read() -- TODO: which size should we request?? local buffer, err = rawio.read(self.fd, 100) if(buffer == nil) then @@ -111,24 +111,24 @@ function exec:new(config, runtype) end return defines.OK end - + local client = {} client.module_instance = inst client.name = inst.name .. "#0" client.pid = child.pid function client:process_response() end function client:process_timeout() end - function client:get_read_handles() + function client:get_read_handles() return { in_handle } end - function client:get_write_handles() + function client:get_write_handles() if(out_handle.out_buffer ~= "") then return { out_handle } else return {} end end - function client:cleanup() + function client:cleanup() util.kill(self.pid) rawio.close(in_handle.fd) rawio.close(out_handle.fd) diff --git a/src/modules/stdio.lua b/src/modules/stdio.lua index 21fd100..9392eb2 100644 --- a/src/modules/stdio.lua +++ b/src/modules/stdio.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> @@ -51,7 +51,7 @@ function stdio:new(config, runtype) rawio.setnonblock(in_handle.fd) in_handle.client_instance = nil in_handle.in_buffer = "" - function in_handle:read() + function in_handle:read() -- TODO: which size should we request?? local buffer, err = rawio.read(0, 100) if(buffer == nil) then @@ -89,16 +89,16 @@ function stdio:new(config, runtype) end return defines.OK end - + local client = {} client.module_instance = inst client.name = inst.name .. "#0" function client:process_response() end function client:process_timeout() end - function client:get_read_handles() + function client:get_read_handles() return { in_handle } end - function client:get_write_handles() + function client:get_write_handles() if(out_handle.out_buffer ~= "") then return { out_handle } else diff --git a/src/modules/stdout.lua b/src/modules/stdout.lua index c8231bb..1ae48fe 100644 --- a/src/modules/stdout.lua +++ b/src/modules/stdout.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> @@ -58,21 +58,21 @@ function stdout:new(config, runtype) log.printf(log.INFO, inst.name .. ": connection error: %s", err) return defines.KILL_MODULE_CLASS end - + self.out_buffer = string.sub(self.out_buffer, len+1) if(self.out_buffer == "") then command_queue:command_sent() end return defines.OK end - + local client = {} client.module_instance = inst client.name = inst.name .. "#0" function client:process_response() end function client:process_timeout() end function client:get_read_handles() return {} end - function client:get_write_handles() + function client:get_write_handles() if(handle.out_buffer ~= "") then return { handle } else diff --git a/src/modules/tcp_connect.lua b/src/modules/tcp_connect.lua index c5171ea..9150c21 100644 --- a/src/modules/tcp_connect.lua +++ b/src/modules/tcp_connect.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> @@ -56,7 +56,7 @@ function tcp_connect:new(config, runtype) handle.in_buffer = "" handle.out_buffer = "" - function handle:read() + function handle:read() -- TODO: which size should we request?? local buffer, err = tcp.recv(self.fd, 100) if(buffer == nil) then @@ -96,10 +96,10 @@ function tcp_connect:new(config, runtype) client.name = inst.name .. "#0" function client:process_response() end function client:process_timeout() end - function client:get_read_handles() + function client:get_read_handles() return { handle } end - function client:get_write_handles() + function client:get_write_handles() if(handle.out_buffer ~= "") then return { handle } else diff --git a/src/modules/tcp_listen.lua b/src/modules/tcp_listen.lua index 365e116..09f3400 100644 --- a/src/modules/tcp_listen.lua +++ b/src/modules/tcp_listen.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 tcp_listen: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 tcp_listen: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 @@ -89,7 +89,7 @@ function tcp_listen:new(config, runtype) else self.in_buffer = response_table:dispatch(self.in_buffer) end - + return defines.OK end function client_handle:write() @@ -131,7 +131,7 @@ function tcp_listen: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 diff --git a/src/options.c b/src/options.c index 7873a84..c9083e8 100644 --- a/src/options.c +++ b/src/options.c @@ -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> @@ -131,9 +131,9 @@ int options_parse_hex_string(const char* hex, buffer_t* buffer) if(hex_len%2) return 1; - if(buffer->buf_) + if(buffer->buf_) free(buffer->buf_); - + buffer->length_ = hex_len/2; buffer->buf_ = malloc(buffer->length_); if(!buffer->buf_) { @@ -189,7 +189,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) PARSE_STRING_PARAM("-l","--lua-code", opt->lua_code_) PARSE_STRING_PARAM("-o","--output", opt->cmd_out_) PARSE_STRING_LIST("-i","--input", opt->cmd_ins_) - else + else return i; } diff --git a/src/options.h b/src/options.h index 47789ad..0187ab0 100644 --- a/src/options.h +++ b/src/options.h @@ -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> diff --git a/src/response_table.lua b/src/response_table.lua index 3f5487b..42fb05b 100644 --- a/src/response_table.lua +++ b/src/response_table.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> @@ -68,6 +68,6 @@ function response_table:dispatch(response_buffer) end end until (not had_match) - + return string.sub(response_buffer, init + 1) end diff --git a/src/sig_handler.c b/src/sig_handler.c index 68ea911..bdd92e2 100644 --- a/src/sig_handler.c +++ b/src/sig_handler.c @@ -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> @@ -172,7 +172,7 @@ static SOCKET server_sock; static DWORD WINAPI signal_connect_thread(void* p) { uint16_t port = *((uint16_t*)p); - + SOCKET client; client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if(client == INVALID_SOCKET) { @@ -200,7 +200,7 @@ static DWORD WINAPI signal_connect_thread(void* p) return -1; } - log_printf(DEBUG, "sig_handler connected to port %d", port); + log_printf(DEBUG, "sig_handler connected to port %d", port); sig_sock_fds[1] = client; @@ -241,7 +241,7 @@ int signal_init() WSACleanup(); return -1; } - + struct sockaddr_in hugo; int hugo_len = sizeof(hugo); if(getsockname(server_sock, (SOCKADDR*) &hugo, &hugo_len) == SOCKET_ERROR) { @@ -250,7 +250,7 @@ int signal_init() WSACleanup(); return -1; } - + if(listen(server_sock, 1) == SOCKET_ERROR) { log_printf(ERROR, "listen() failed: 0x%04X", WSAGetLastError()); closesocket(server_sock); @@ -278,7 +278,7 @@ int signal_init() } WaitForSingleObject(t, INFINITE); - + if(!SetConsoleCtrlHandler(signal_ctrl_handler, 1)) { log_printf(ERROR, "adding console ctrl handler failed: 0x%04X" , GetLastError()); } diff --git a/src/sig_handler.h b/src/sig_handler.h index 558f5d7..e6788be 100644 --- a/src/sig_handler.h +++ b/src/sig_handler.h @@ -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> diff --git a/src/string_list.c b/src/string_list.c index 9b0da4d..0856c11 100644 --- a/src/string_list.c +++ b/src/string_list.c @@ -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> @@ -40,7 +40,7 @@ void string_list_init(string_list_t* list) { if(!list) return; - + list->first_ = NULL; } @@ -101,7 +101,7 @@ void string_list_print(string_list_t* list, const char* head, const char* tail) { if(!list) return; - + string_list_element_t* tmp = list->first_; while(tmp) { printf("%s%s%s", head, tmp->string_, tail); diff --git a/src/string_list.h b/src/string_list.h index 5e0175f..c1f9e7a 100644 --- a/src/string_list.h +++ b/src/string_list.h @@ -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> |