txtinfo: put the plugin init hook in the functions table
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 2 Dec 2015 10:31:04 +0000 (11:31 +0100)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 2 Dec 2015 17:41:14 +0000 (18:41 +0100)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/info/info_types.h
lib/txtinfo/src/olsrd_txtinfo.c

index 7b51b48..c750c0e 100644 (file)
 /* 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;
index 74a9379..a83d02a 100644 (file)
@@ -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;