From 474aab6325bf94724874cb74a9b56d9da739e1b8 Mon Sep 17 00:00:00 2001 From: Ivo Timmermans Date: Thu, 2 May 2002 11:52:28 +0000 Subject: [PATCH] Callbacks --- src/callbacks.c | 39 +++++++++++++++++++++++++++++++++++++++ src/callbacks.h | 7 +++++++ 2 files changed, 46 insertions(+) create mode 100644 src/callbacks.c create mode 100644 src/callbacks.h diff --git a/src/callbacks.c b/src/callbacks.c new file mode 100644 index 00000000..b30e30d3 --- /dev/null +++ b/src/callbacks.c @@ -0,0 +1,39 @@ +#include "config.h" + +#include + +#include +#include + +#include "callbacks.h" +#include "process.h" + +#include "system.h" + +void hook_node_visible(const char *hooktype, va_list ap) +{ + char *name; + node_t *n; + + n = va_arg(ap, node_t*); + asprintf(&name, "hosts/%s-down", n->name); + execute_script(name); + free(name); +} + +void hook_node_invisible(const char *hooktype, va_list ap) +{ + char *name; + node_t *n; + + n = va_arg(ap, node_t*); + asprintf(&name, "hosts/%s-up", n->name); + execute_script(name); + free(name); +} + +void init_callbacks(void) +{ + add_hook("node-visible", hook_node_visible); + add_hook("node-invisible", hook_node_invisible); +} diff --git a/src/callbacks.h b/src/callbacks.h new file mode 100644 index 00000000..91d6321d --- /dev/null +++ b/src/callbacks.h @@ -0,0 +1,7 @@ + +#ifndef __TINC_CALLBACKS_H__ +#define __TINC_CALLBACKS_H__ + +extern void init_callbacks(void); + +#endif /* __TINC_CALLBACKS_H__ */