[Olsr-dev] [PATCH v1 036/115] txtinfo: put output start/end in the functions table

Ferry Huberts (spam-protected)
Wed Dec 2 21:28:09 CET 2015


From: Ferry Huberts <(spam-protected)>

Signed-off-by: Ferry Huberts <(spam-protected)>
---
 lib/info/info_types.h           | 3 +++
 lib/txtinfo/src/olsrd_txtinfo.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/lib/info/info_types.h b/lib/info/info_types.h
index cbf3141..8d051bb 100644
--- a/lib/info/info_types.h
+++ b/lib/info/info_types.h
@@ -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;
diff --git a/lib/txtinfo/src/olsrd_txtinfo.c b/lib/txtinfo/src/olsrd_txtinfo.c
index be7b467..e1f6ddf 100644
--- a/lib/txtinfo/src/olsrd_txtinfo.c
+++ b/lib/txtinfo/src/olsrd_txtinfo.c
@@ -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);
-- 
2.5.0




More information about the Olsr-dev mailing list