jsoninfo: clearer distinction between JSON and non-JSON blocks
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 20 Apr 2015 12:21:33 +0000 (14:21 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 20 Apr 2015 12:38:42 +0000 (14:38 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/jsoninfo/src/olsrd_jsoninfo.c

index 029bade..be631e4 100644 (file)
@@ -1207,44 +1207,44 @@ static void send_info(unsigned int send_what, int the_socket) {
   abuf_init(&abuf, 32768);
 
   // only add if outputing JSON
-  if (send_what & SIW_ALL)
+  if (send_what & SIW_ALL) {
     abuf_puts(&abuf, "{");
 
-  if ((send_what & SIW_LINKS) == SIW_LINKS)
-    ipc_print_links(&abuf);
-  if ((send_what & SIW_NEIGHBORS) == SIW_NEIGHBORS)
-    ipc_print_neighbors(&abuf);
-  if ((send_what & SIW_TOPOLOGY) == SIW_TOPOLOGY)
-    ipc_print_topology(&abuf);
-  if ((send_what & SIW_HNA) == SIW_HNA)
-    ipc_print_hna(&abuf);
-  if ((send_what & SIW_MID) == SIW_MID)
-    ipc_print_mid(&abuf);
-  if ((send_what & SIW_ROUTES) == SIW_ROUTES)
-    ipc_print_routes(&abuf);
-  if ((send_what & SIW_GATEWAYS) == SIW_GATEWAYS)
-    ipc_print_gateways(&abuf);
-  if ((send_what & SIW_INTERFACES) == SIW_INTERFACES)
-    ipc_print_interfaces(&abuf);
-  if ((send_what & SIW_CONFIG) == SIW_CONFIG) {
-    if (send_what != SIW_CONFIG)
-      abuf_puts(&abuf, ",");
-    ipc_print_config(&abuf);
-  }
-  if ((send_what & SIW_PLUGINS) == SIW_PLUGINS)
-    ipc_print_plugins(&abuf);
+    if ((send_what & SIW_LINKS) == SIW_LINKS)
+      ipc_print_links(&abuf);
+    if ((send_what & SIW_NEIGHBORS) == SIW_NEIGHBORS)
+      ipc_print_neighbors(&abuf);
+    if ((send_what & SIW_TOPOLOGY) == SIW_TOPOLOGY)
+      ipc_print_topology(&abuf);
+    if ((send_what & SIW_HNA) == SIW_HNA)
+      ipc_print_hna(&abuf);
+    if ((send_what & SIW_MID) == SIW_MID)
+      ipc_print_mid(&abuf);
+    if ((send_what & SIW_ROUTES) == SIW_ROUTES)
+      ipc_print_routes(&abuf);
+    if ((send_what & SIW_GATEWAYS) == SIW_GATEWAYS)
+      ipc_print_gateways(&abuf);
+    if ((send_what & SIW_INTERFACES) == SIW_INTERFACES)
+      ipc_print_interfaces(&abuf);
+    if ((send_what & SIW_CONFIG) == SIW_CONFIG) {
+      if (send_what != SIW_CONFIG)
+        abuf_puts(&abuf, ",");
+      ipc_print_config(&abuf);
+    }
+    if ((send_what & SIW_PLUGINS) == SIW_PLUGINS)
+      ipc_print_plugins(&abuf);
 
-  /* output overarching meta data last so we can use abuf_json_* functions, they add a comma at the beginning */
-  if (send_what & SIW_ALL) {
-    abuf_json_int(&abuf, "systemTime", time(NULL));
-    abuf_json_int(&abuf, "timeSinceStartup", now_times);
-    if (*uuid)
-      abuf_json_string(&abuf, "uuid", uuid);
-    abuf_puts(&abuf, "}\n");
-  }
+    /* output overarching meta data last so we can use abuf_json_* functions, they add a comma at the beginning */
+    if (send_what & SIW_ALL) {
+      abuf_json_int(&abuf, "systemTime", time(NULL));
+      abuf_json_int(&abuf, "timeSinceStartup", now_times);
+      if (*uuid)
+        abuf_json_string(&abuf, "uuid", uuid);
 
-  /* this outputs the olsrd.conf text directly, not JSON */
-  if ((send_what & SIW_OLSRD_CONF) == SIW_OLSRD_CONF) {
+      abuf_puts(&abuf, "}\n");
+    }
+  } else if (send_what & SIW_OLSRD_CONF) {
+    /* this outputs the olsrd.conf text directly, not JSON */
     ipc_print_olsrd_conf(&abuf);
   }