txtinfo: put output start/end in the functions table
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 2 Dec 2015 10:40:07 +0000 (11:40 +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 cbf3141..8d051bb 100644 (file)
@@ -75,6 +75,7 @@
 typedef void (*init_plugin)(const char *plugin_name);
 typedef bool (*determine_command)(const char *str, unsigned int siw);
 typedef const char * (*mime_type)(unsigned int send_what);
+typedef void (*output_start_end)(struct autobuf *abuf);
 typedef void (*printer_neighbors)(struct autobuf *abuf, bool list_2hop);
 typedef void (*printer_generic)(struct autobuf *abuf);
 
@@ -82,6 +83,8 @@ typedef struct {
     init_plugin init;
     determine_command is_command;
     mime_type determine_mime_type;
+    output_start_end output_start;
+    output_start_end output_end;
     printer_neighbors neighbors;
     printer_generic links;
     printer_generic routes;
index be7b467..e1f6ddf 100644 (file)
@@ -89,6 +89,8 @@ static printer_functions_t printer_functions = { //
         .init = NULL, //
         .is_command = &isCommand, //
         .determine_mime_type = NULL, //
+        .output_start = NULL, //
+        .output_end = NULL, //
         .neighbors = &ipc_print_neighbors, //
         .links = &ipc_print_links, //
         .routes = &ipc_print_routes, //
@@ -411,6 +413,9 @@ static void send_info(unsigned int send_what, int the_socket) {
 
   // only add if normal format
   if (send_what & SIW_ALL) {
+    if (printer_functions.output_start)
+      (*printer_functions.output_start)(&abuf);
+
     if ((send_what & SIW_LINKS) && printer_functions.links)
       (*printer_functions.links)(&abuf);
     if ((send_what & SIW_NEIGHBORS) && printer_functions.neighbors)
@@ -437,6 +442,9 @@ static void send_info(unsigned int send_what, int the_socket) {
       (*printer_functions.version)(&abuf);
     if ((send_what & SIW_PLUGINS) && printer_functions.plugins)
       (*printer_functions.plugins)(&abuf);
+
+    if (printer_functions.output_end)
+      (*printer_functions.output_end)(&abuf);
   } else if ((send_what & SIW_OLSRD_CONF) && printer_functions.olsrd_conf) {
     /* this outputs the olsrd.conf text directly, not normal format */
     (*printer_functions.olsrd_conf)(&abuf);