jsoninfo: move code from olsr_jsoninfo into olsr_plugin
[olsrd.git] / lib / jsoninfo / src / olsrd_plugin.c
index 7794a0c..fffdfe2 100644 (file)
  * Dynamic linked library for the olsr.org olsr daemon
  */
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <arpa/inet.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-
 #include "olsrd_plugin.h"
-#include "olsrd_jsoninfo.h"
-#include "defs.h"
-#include "../../info/info_types.h"
+#include "../../info/olsrd_info.h"
+#include "jsoninfo_printers.h"
 
-#define PLUGIN_NAME    "OLSRD jsoninfo plugin"
+#define PLUGIN_NAME "JSONINFO"
+#define PLUGIN_TITLE    "OLSRD jsoninfo plugin"
 #define PLUGIN_VERSION "0.0"
 #define PLUGIN_AUTHOR   "Hans-Christoph Steiner"
-#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
+#define MOD_DESC PLUGIN_TITLE " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
 #define PLUGIN_INTERFACE_VERSION 5
 
+static printer_functions_t printer_functions = { //
+    //
+        .init = &plugin_init, //
+        .is_command = &isCommand, //
+        .determine_mime_type = &determine_mime_type, //
+        .output_start = &output_start, //
+        .output_end = &output_end, //
+        .neighbors = &ipc_print_neighbors, //
+        .links = &ipc_print_links, //
+        .routes = &ipc_print_routes, //
+        .topology = &ipc_print_topology, //
+        .hna = &ipc_print_hna, //
+        .mid = &ipc_print_mid, //
+        .gateways = &ipc_print_gateways, //
+        .sgw = &ipc_print_sgw, //
+        .version = &ipc_print_version, //
+        .olsrd_conf = &ipc_print_olsrd_conf, //
+        .interfaces = &ipc_print_interfaces, //
+        .config = &ipc_print_config, //
+        .plugins = &ipc_print_plugins //
+    };
+
+
 info_plugin_config_t info_plugin_config;
 char uuidfile[FILENAME_MAX];
 
@@ -106,6 +122,23 @@ static void my_fini(void) {
   olsr_plugin_exit();
 }
 
+/**
+ *Do initialization here
+ *
+ *This function is called by the my_init
+ *function in uolsrd_plugin.c
+ */
+int olsrd_plugin_init(void) {
+  return info_plugin_init(PLUGIN_NAME, &printer_functions, &info_plugin_config);
+}
+
+/**
+ * destructor - called at unload
+ */
+void olsr_plugin_exit(void) {
+  info_plugin_exit();
+}
+
 int olsrd_plugin_interface_version(void) {
   return PLUGIN_INTERFACE_VERSION;
 }