diff options
-rw-r--r-- | LICENSE | 2 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | client_list.c | 2 | ||||
-rw-r--r-- | client_list.h | 2 | ||||
-rw-r--r-- | command_queue.c | 20 | ||||
-rw-r--r-- | command_queue.h | 12 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | datatypes.h | 2 | ||||
-rw-r--r-- | heartbeatclient.c | 2 | ||||
-rw-r--r-- | key_value_storage.c | 8 | ||||
-rw-r--r-- | key_value_storage.h | 2 | ||||
-rw-r--r-- | l_cmd.c | 2 | ||||
-rw-r--r-- | l_cmd.h | 2 | ||||
-rw-r--r-- | l_log.c | 24 | ||||
-rw-r--r-- | l_log.h | 14 | ||||
-rw-r--r-- | l_sig_handler.c | 22 | ||||
-rw-r--r-- | l_sig_handler.h | 14 | ||||
-rw-r--r-- | log.c | 2 | ||||
-rw-r--r-- | log.h | 2 | ||||
-rw-r--r-- | log_targets.h | 18 | ||||
-rw-r--r-- | luaclient.c | 14 | ||||
-rw-r--r-- | mode-tcpserver.lua | 22 | ||||
-rw-r--r-- | mode-watch.lua | 44 | ||||
-rw-r--r-- | options.c | 8 | ||||
-rw-r--r-- | options.h | 2 | ||||
-rw-r--r-- | serialclient.c | 2 | ||||
-rw-r--r-- | silence-watch.lua | 28 | ||||
-rw-r--r-- | stdioclient.c | 8 | ||||
-rw-r--r-- | switchctl.c | 2 | ||||
-rw-r--r-- | utils.c | 17 | ||||
-rw-r--r-- | utils.h | 2 |
31 files changed, 149 insertions, 156 deletions
@@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -1,7 +1,7 @@ ## ## rhctl ## -## Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> +## Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> ## ## This file is part of rhctl. ## diff --git a/client_list.c b/client_list.c index ff86878..187d458 100644 --- a/client_list.c +++ b/client_list.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/client_list.h b/client_list.h index 428188e..1be6bb3 100644 --- a/client_list.h +++ b/client_list.h @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/command_queue.c b/command_queue.c index 0351f5c..8c697db 100644 --- a/command_queue.c +++ b/command_queue.c @@ -1,22 +1,22 @@ /* - * door_daemon + * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * - * This file is part of door_daemon. + * This file is part of rhctl. * - * door_daemon is free software: you can redistribute it and/or modify + * rhctl 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. * - * door_daemon is distributed in the hope that it will be useful, + * rhctl 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 door_daemon. If not, see <http://www.gnu.org/licenses/>. + * along with rhctl. If not, see <http://www.gnu.org/licenses/>. */ #include <stdlib.h> @@ -27,7 +27,7 @@ cmd_t* cmd_get_last(cmd_t* first) { - if(!first) + if(!first) return NULL; while(first->next) { @@ -66,7 +66,7 @@ int cmd_push(cmd_t** first, int fd, cmd_id_t cmd, const char* param) *first = new_cmd; return 0; } - + cmd_get_last(*first)->next = new_cmd; return 0; @@ -93,7 +93,7 @@ int cmd_has_expired(cmd_t cmd) void cmd_pop(cmd_t** first) { - if(!first || !(*first)) + if(!first || !(*first)) return; cmd_t* deletee = *first; @@ -105,7 +105,7 @@ void cmd_pop(cmd_t** first) void cmd_clear(cmd_t** first) { - if(!first || !(*first)) + if(!first || !(*first)) return; while(*first) { diff --git a/command_queue.h b/command_queue.h index dbd2091..8424791 100644 --- a/command_queue.h +++ b/command_queue.h @@ -1,22 +1,22 @@ /* - * door_daemon + * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * - * This file is part of door_daemon. + * This file is part of rhctl. * - * door_daemon is free software: you can redistribute it and/or modify + * rhctl 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. * - * door_daemon is distributed in the hope that it will be useful, + * rhctl 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 door_daemon. If not, see <http://www.gnu.org/licenses/>. + * along with rhctl. If not, see <http://www.gnu.org/licenses/>. */ #ifndef RHCTL_command_queue_h_INCLUDED @@ -3,7 +3,7 @@ # # rhctl # -# Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> +# Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> # # This file is part of rhctl. # diff --git a/datatypes.h b/datatypes.h index e38d121..1eae397 100644 --- a/datatypes.h +++ b/datatypes.h @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/heartbeatclient.c b/heartbeatclient.c index 162660b..7fb12bb 100644 --- a/heartbeatclient.c +++ b/heartbeatclient.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/key_value_storage.c b/key_value_storage.c index 7f4b584..05dc288 100644 --- a/key_value_storage.c +++ b/key_value_storage.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -48,11 +48,11 @@ int key_value_storage_add(key_value_storage_t* stor, const char* key, const char return -1; int ret = string_list_add(&(stor->keys_), key); - if(ret!=0) + if(ret!=0) return ret; ret = string_list_add(&(stor->values_), value); - if(ret!=0) + if(ret!=0) return ret; return 0; @@ -68,7 +68,7 @@ char* key_value_storage_find(key_value_storage_t* stor, const char* key) while(v && k) { if(!strcmp(k->string_, key)) return v->string_; - + k = k->next_; v = v->next_; } diff --git a/key_value_storage.h b/key_value_storage.h index bf7a493..2b5a734 100644 --- a/key_value_storage.h +++ b/key_value_storage.h @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -1,14 +1,14 @@ /* * anylike * - * anylike is an IKEv2 Implementation written in Lua and C. It's main - * design goal is to provide anytun and uanytun or any other SATP - * implementation with a key exchange mechanism but it should also be - * possible to use anylike as key exchange daemon for IPSec security - * associations. The use of Lua guarantees that anylike is easily - * portable to many platforms including very small ones like wireless + * anylike is an IKEv2 Implementation written in Lua and C. It's main + * design goal is to provide anytun and uanytun or any other SATP + * implementation with a key exchange mechanism but it should also be + * possible to use anylike as key exchange daemon for IPSec security + * associations. The use of Lua guarantees that anylike is easily + * portable to many platforms including very small ones like wireless * routers. - * + * * * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org> * Christian Pointner <equinox@anylike.org> @@ -63,7 +63,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; @@ -83,22 +83,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"); @@ -1,14 +1,14 @@ /* * anylike * - * anylike is an IKEv2 Implementation written in Lua and C. It's main - * design goal is to provide anytun and uanytun or any other SATP - * implementation with a key exchange mechanism but it should also be - * possible to use anylike as key exchange daemon for IPSec security - * associations. The use of Lua guarantees that anylike is easily - * portable to many platforms including very small ones like wireless + * anylike is an IKEv2 Implementation written in Lua and C. It's main + * design goal is to provide anytun and uanytun or any other SATP + * implementation with a key exchange mechanism but it should also be + * possible to use anylike as key exchange daemon for IPSec security + * associations. The use of Lua guarantees that anylike is easily + * portable to many platforms including very small ones like wireless * routers. - * + * * * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org> * Christian Pointner <equinox@anylike.org> diff --git a/l_sig_handler.c b/l_sig_handler.c index 0bdcffc..1be30ce 100644 --- a/l_sig_handler.c +++ b/l_sig_handler.c @@ -1,14 +1,14 @@ /* * anylike * - * anylike is an IKEv2 Implementation written in Lua and C. It's main - * design goal is to provide anytun and uanytun or any other SATP - * implementation with a key exchange mechanism but it should also be - * possible to use anylike as key exchange daemon for IPSec security - * associations. The use of Lua guarantees that anylike is easily - * portable to many platforms including very small ones like wireless + * anylike is an IKEv2 Implementation written in Lua and C. It's main + * design goal is to provide anytun and uanytun or any other SATP + * implementation with a key exchange mechanism but it should also be + * possible to use anylike as key exchange daemon for IPSec security + * associations. The use of Lua guarantees that anylike is easily + * portable to many platforms including very small ones like wireless * routers. - * + * * * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org> * Christian Pointner <equinox@anylike.org> @@ -42,7 +42,7 @@ static int l_signal_getfd(lua_State *L) luaL_error(L, "can't retreive signal fd"); lua_pushliteral(L, "fd"); - lua_gettable(L, -2); + lua_gettable(L, -2); return 1; } @@ -85,14 +85,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/l_sig_handler.h b/l_sig_handler.h index 06a5f75..447b95e 100644 --- a/l_sig_handler.h +++ b/l_sig_handler.h @@ -1,14 +1,14 @@ /* * anylike * - * anylike is an IKEv2 Implementation written in Lua and C. It's main - * design goal is to provide anytun and uanytun or any other SATP - * implementation with a key exchange mechanism but it should also be - * possible to use anylike as key exchange daemon for IPSec security - * associations. The use of Lua guarantees that anylike is easily - * portable to many platforms including very small ones like wireless + * anylike is an IKEv2 Implementation written in Lua and C. It's main + * design goal is to provide anytun and uanytun or any other SATP + * implementation with a key exchange mechanism but it should also be + * possible to use anylike as key exchange daemon for IPSec security + * associations. The use of Lua guarantees that anylike is easily + * portable to many platforms including very small ones like wireless * routers. - * + * * * Copyright (C) 2009-2010 Markus Grueneis <gimpf@anylike.org> * Christian Pointner <equinox@anylike.org> @@ -13,7 +13,7 @@ * message authentication based on the methodes used by SRTP. It is * intended to deliver a generic, scaleable and secure solution for * tunneling and relaying of packets of any protocol. - * + * * * Copyright (C) 2007-2010 Christian Pointner <equinox@anytun.org> * @@ -13,7 +13,7 @@ * message authentication based on the methodes used by SRTP. It is * intended to deliver a generic, scaleable and secure solution for * tunneling and relaying of packets of any protocol. - * + * * * Copyright (C) 2007-2010 Christian Pointner <equinox@anytun.org> * diff --git a/log_targets.h b/log_targets.h index 4a19d8e..b6c3ae5 100644 --- a/log_targets.h +++ b/log_targets.h @@ -13,7 +13,7 @@ * message authentication based on the methodes used by SRTP. It is * intended to deliver a generic, scaleable and secure solution for * tunneling and relaying of packets of any protocol. - * + * * * Copyright (C) 2007-2010 Christian Pointner <equinox@anytun.org> * @@ -42,7 +42,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); @@ -79,7 +79,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; @@ -95,7 +95,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); @@ -116,13 +116,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; @@ -157,7 +157,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) @@ -209,7 +209,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; @@ -224,7 +224,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/luaclient.c b/luaclient.c index c3f1766..e758b7d 100644 --- a/luaclient.c +++ b/luaclient.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -45,7 +45,7 @@ static const luaL_Reg anylike_lualibs[] = { {"", luaopen_base}, - {LUA_LOADLIBNAME, luaopen_package}, + {LUA_LOADLIBNAME, luaopen_package}, {LUA_TABLIBNAME, luaopen_table}, {LUA_STRLIBNAME, luaopen_string}, {LUA_MATHLIBNAME, luaopen_math}, @@ -135,7 +135,7 @@ int main_loop(int cmd_fd, options_t* opt) int ret = init_main_loop(L, opt->lua_file_); if(!ret) ret = call_main_loop(L, cmd_fd, opt); - + lua_close(L); return ret; } @@ -175,7 +175,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); @@ -236,13 +236,13 @@ int main(int argc, char* argv[]) cmd_fd = connect_command_socket(opt.command_sock_); if(cmd_fd < 0) ret = 2; - else { + else { ret = main_loop(cmd_fd, &opt); - } + } if(ret == 2) { log_printf(ERROR, "socket error, trying to reconnect in 5 seconds.."); - + if(cmd_fd > 0) close(cmd_fd); sleep(5); diff --git a/mode-tcpserver.lua b/mode-tcpserver.lua index fa76574..640ee30 100644 --- a/mode-tcpserver.lua +++ b/mode-tcpserver.lua @@ -1,7 +1,7 @@ -- -- rhctl -- --- Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> +-- Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> -- -- This file is part of rhctl. -- @@ -25,7 +25,7 @@ current_mode = nil function init_server(host, port) local server = assert(socket.tcp()) - + assert(server:setoption('reuseaddr', true)) assert(server:bind(host, port)) assert(server:listen(5)) @@ -75,7 +75,7 @@ end function clients_get_writeables() local fds = {} - + for _, client in ipairs(clients) do if client.buffer ~= "" then table.insert(fds, client) @@ -93,7 +93,7 @@ end function process_cmd(message) log.printf(log.DEBUG, "received message: '%s'", message) - + local new_mode = nil local exps = { "Current Mode: (%a+)", "new Mode: (%a+)" } for _, exp in ipairs(exps) do @@ -103,25 +103,25 @@ function process_cmd(message) break end end - + if(new_mode and new_mode ~= current_mode) then clients_senddata(new_mode) current_mode = new_mode end - + return 0 end -function main_loop(opt) +function main_loop(opt) log.printf(log.NOTICE, "main_loop started") local sig = signal.init() local cmdfd = cmd.init() - + local server = init_server("*", "2345") cmd.send_string("listen mode"); cmd.send_string("status"); - + local return_value = 0 while return_value == 0 do local readable, writeable, err = socket.select({ sig , cmdfd , server , unpack(clients) }, clients_get_writeables()) @@ -138,7 +138,7 @@ function main_loop(opt) if(return_value ~= 0) then break end elseif input == server then local client = server:accept() - if(client == nil) then + if(client == nil) then return_value =-3 break else @@ -166,7 +166,7 @@ function main_loop(opt) end server:close() - cleanup_clients() + cleanup_clients() signal.stop() return return_value diff --git a/mode-watch.lua b/mode-watch.lua index abea7b9..7f1e745 100644 --- a/mode-watch.lua +++ b/mode-watch.lua @@ -1,7 +1,7 @@ -- -- rhctl -- --- Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> +-- Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> -- -- This file is part of rhctl. -- @@ -22,23 +22,23 @@ socket = require("socket") function set_master_led() - os.execute("/sbin/led.sh set master") - os.execute("/sbin/led.sh clear standby") + os.execute("/sbin/led.sh set master") + os.execute("/sbin/led.sh clear standby") end -function set_standby_led() - os.execute("/sbin/led.sh clear master") - os.execute("/sbin/led.sh set standby") +function set_standby_led() + os.execute("/sbin/led.sh clear master") + os.execute("/sbin/led.sh set standby") end function clear_leds() - os.execute("/sbin/led.sh clear master") - os.execute("/sbin/led.sh clear standby") + os.execute("/sbin/led.sh clear master") + os.execute("/sbin/led.sh clear standby") end function send_mail(address, subject, bodytext) local fp = assert(io.popen("/usr/sbin/mini_sendmail -smailrelay -fnoreply@helsinki.at " .. address, "w")) - + fp:write("Subject: " .. subject .. "\n") fp:write("To: " .. address .. "\n") fp:write("\n") @@ -51,7 +51,7 @@ current_mode = nil function process_cmd(message) log.printf(log.DEBUG, "received message: '%s'", message) - + local new_mode = nil local exps = { "Current Mode: (%a+)", "new Mode: (%a+)" } for _, exp in ipairs(exps) do @@ -69,32 +69,32 @@ function process_cmd(message) end end end - + if(new_mode and new_mode ~= current_mode) then log.printf(log.NOTICE, "mode is now " .. new_mode) if(current_mode == nil) then - send_mail("logs@helsinki.at", "[RHCTL] (re)started mode is now " .. new_mode, + send_mail("logs@helsinki.at", "[RHCTL] (re)started mode is now " .. new_mode, "RHCTL just (re)started current mode is " .. new_mode) else - send_mail("logs@helsinki.at", "[RHCTL] mode changed to " .. new_mode, + send_mail("logs@helsinki.at", "[RHCTL] mode changed to " .. new_mode, "RHCTL just switched from " .. current_mode .. " to " .. new_mode) end current_mode = new_mode end - + return 0 end -function main_loop(opt) +function main_loop(opt) log.printf(log.NOTICE, "main_loop started") local sig = signal.init() local cmdfd = cmd.init() - + cmd.send_string("listen mode"); cmd.send_string("status"); - + clear_leds() - + local return_value = 0 while return_value == 0 do local readable, _, err = socket.select({ sig , cmdfd }, nil) @@ -106,7 +106,7 @@ function main_loop(opt) if(input == sig) then return_value = signal.handle() if(return_value == 1) then break end - else + else if(input == cmdfd) then return_value = cmd.recv_data(process_cmd) if(return_value ~= 0) then break end @@ -119,9 +119,9 @@ function main_loop(opt) end end end - - clear_leds() - + + clear_leds() + signal.stop() return return_value end @@ -2,7 +2,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -120,9 +120,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_) { @@ -201,7 +201,7 @@ int options_parse(options_t* opt, int argc, char* argv[]) #ifdef OPT_LUACLIENT PARSE_STRING_PARAM("-f","--lua-file", opt->lua_file_) #endif - else + else return i; } @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/serialclient.c b/serialclient.c index cee4ec5..c0664a6 100644 --- a/serialclient.c +++ b/serialclient.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * diff --git a/silence-watch.lua b/silence-watch.lua index cc47437..d3c1b48 100644 --- a/silence-watch.lua +++ b/silence-watch.lua @@ -1,7 +1,7 @@ -- -- rhctl -- --- Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> +-- Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> -- -- This file is part of rhctl. -- @@ -23,7 +23,7 @@ socket = require("socket") function send_mail(address, subject, bodytext) local fp = assert(io.popen("/usr/sbin/mini_sendmail -smailrelay -fnoreply@helsinki.at " .. address, "w")) - + fp:write("Subject: " .. subject .. "\n") fp:write("To: " .. address .. "\n") fp:write("\n") @@ -36,35 +36,35 @@ current_state = nil function process_cmd(message) log.printf(log.DEBUG, "received message: '%s'", message) - + silence_state = string.match(message, "S0S,(%d)") if(silence_state and silence_state ~= current_state) then if(silence_state == "0") then log.printf(log.NOTICE, "seen some noise") - send_mail("silence@helsinki.at", "[RHCTL] sees some noise", - "There is some noise at output 1 of the audioswitch\nCurrent State is: " .. message) + send_mail("silence@helsinki.at", "[RHCTL] sees some noise", + "There is some noise at output 1 of the audioswitch\nCurrent State is: " .. message) else if (silence_state == "1") then log.printf(log.NOTICE, "silence detected") - send_mail("silence@helsinki.at", "[RHCTL] silence detected ", - "Silence detected at output 1 of the audioswitch, make some noise!!\nCurrent State is: " .. message) + send_mail("silence@helsinki.at", "[RHCTL] silence detected ", + "Silence detected at output 1 of the audioswitch, make some noise!!\nCurrent State is: " .. message) end end - current_state = silence_state + current_state = silence_state end - + return 0 end -function main_loop(opt) +function main_loop(opt) log.printf(log.NOTICE, "main_loop started") local sig = signal.init() local cmdfd = cmd.init() - + cmd.send_string("listen silence"); cmd.send_string("switch *0SS"); - + local return_value = 0 while return_value == 0 do local readable, _, err = socket.select({ sig , cmdfd }, nil) @@ -76,7 +76,7 @@ function main_loop(opt) if(input == sig) then return_value = signal.handle() if(return_value == 1) then break end - else + else if(input == cmdfd) then return_value = cmd.recv_data(process_cmd) if(return_value ~= 0) then break end @@ -89,7 +89,7 @@ function main_loop(opt) end end end - + signal.stop() return return_value end diff --git a/stdioclient.c b/stdioclient.c index 5993282..be7d091 100644 --- a/stdioclient.c +++ b/stdioclient.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -50,7 +50,7 @@ int process_data(int src_fd, int dest_fd) return ret; log_printf(DEBUG, "read %d bytes from fd (%d)", ret, src_fd); - + int len = ret; int offset = 0; for(;;) { @@ -103,7 +103,7 @@ int main_loop(int cmd_fd, options_t* opt) if(FD_ISSET(sig_fd, &tmpfds)) if(signal_handle()) return_value = 1; - + if(FD_ISSET(0, &tmpfds)) return_value = process_data(0, cmd_fd); @@ -150,7 +150,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); diff --git a/switchctl.c b/switchctl.c index 7463eb7..7917a89 100644 --- a/switchctl.c +++ b/switchctl.c @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * @@ -52,7 +52,7 @@ int init_command_socket(const char* path) log_printf(ERROR, "unable to bind to '%s': %s", local.sun_path, strerror(errno)); return -1; } - + ret = listen(fd, 4); if(ret) { log_printf(ERROR, "unable to listen on command socket: %s", local.sun_path, strerror(errno)); @@ -60,7 +60,7 @@ int init_command_socket(const char* path) } log_printf(INFO, "now listening on %s for incoming commands", path); - + return fd; } @@ -113,25 +113,18 @@ int send_string(int fd, const char* string) int setup_tty(int fd, speed_t speed) { struct termios tmio; - + int ret = tcgetattr(fd, &tmio); if(ret) { log_printf(ERROR, "Error on tcgetattr(): %s", strerror(errno)); return ret; } -// tmio.c_iflag |= ; tmio.c_iflag &= ~(INLCR | ICRNL | IGNCR | IXON | IXOFF); - -// tmio.c_oflag |= ; tmio.c_oflag &= ~(ONLCR | OCRNL | ONOCR | ONLRET); - tmio.c_cflag |= CS8 | CLOCAL | CREAD; tmio.c_cflag &= ~(CSTOPB | PARENB); - -// tmio.c_lflag |= ; tmio.c_lflag &= ~(ICANON | ECHO); - tmio.c_cc[VTIME] = 0; tmio.c_cc[VMIN] = 1; @@ -152,7 +145,7 @@ int setup_tty(int fd, speed_t speed) log_printf(ERROR, "Error on tcsetattr(): %s", strerror(errno)); return ret; } - + ret = tcflush(fd, TCIFLUSH); if(ret) { log_printf(ERROR, "Error on tcflush(): %s", strerror(errno)); @@ -1,7 +1,7 @@ /* * rhctl * - * Copyright (C) 2009 Christian Pointner <equinox@spreadspace.org> + * Copyright (C) 2009-2013 Christian Pointner <equinox@helsinki.at> * * This file is part of rhctl. * |