[Olsr-dev] [PATCH v1 032/115] txtinfo: put the plugin init hook in the functions table
Ferry Huberts
(spam-protected)
Wed Dec 2 21:28:05 CET 2015
From: Ferry Huberts <(spam-protected)>
Signed-off-by: Ferry Huberts <(spam-protected)>
---
lib/info/info_types.h | 2 ++
lib/txtinfo/src/olsrd_txtinfo.c | 9 ++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/info/info_types.h b/lib/info/info_types.h
index 7b51b48..c750c0e 100644
--- a/lib/info/info_types.h
+++ b/lib/info/info_types.h
@@ -71,11 +71,13 @@
/* this data is not normal format but olsrd.conf format */
#define SIW_OLSRD_CONF 0x2000
+typedef void (*init_plugin)(const char *plugin_name);
typedef const char * (*mime_type)(unsigned int send_what);
typedef void (*printer_neighbors)(struct autobuf *abuf, bool list_2hop);
typedef void (*printer_generic)(struct autobuf *abuf);
typedef struct {
+ init_plugin init;
mime_type determine_mime_type;
printer_neighbors neighbors;
printer_generic links;
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index 74a9379..a83d02a 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -86,6 +86,7 @@ static struct timer_entry *writetimer_entry;
static printer_functions_t printer_functions = { //
//
+ .init = NULL, //
.determine_mime_type = NULL, //
.neighbors = &ipc_print_neighbors, //
.links = &ipc_print_links, //
@@ -153,10 +154,6 @@ static void determine_action(unsigned int *send_what, char *requ) {
}
}
-static void plugin_init(void) {
- /* nothing to do */
-}
-
/**
*Do initialization here
*
@@ -168,7 +165,9 @@ int olsrd_plugin_init(void) {
ipc_socket = -1;
memset(&outbuffer, 0, sizeof(outbuffer));
- plugin_init();
+ if (printer_functions.init) {
+ (*printer_functions.init)(PLUGIN_NAME);
+ }
plugin_ipc_init();
return 1;
--
2.5.0
More information about the Olsr-dev
mailing list