From 7b45d3939d6e6ad5cdedd5943f020de6e28f3246 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Fri, 14 Aug 2020 14:27:23 -0500
Subject: [PATCH] ifctrstat: Add -n option to omit label printing

---
 cmd/ifctrstat.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/cmd/ifctrstat.c b/cmd/ifctrstat.c
index 1d376cd..0409438 100644
--- a/cmd/ifctrstat.c
+++ b/cmd/ifctrstat.c
@@ -14,9 +14,10 @@
  */
 
 #include <errno.h>
+#include <getopt.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
-#include <getopt.h>
 #include "libifupdown/libifupdown.h"
 #include "cmd/multicall.h"
 
@@ -25,6 +26,8 @@ extern int avail_counters_count;
 
 extern const char *read_counter(const char *interface, const char *counter);
 
+static bool show_label = true;
+
 static bool
 counter_is_valid(const char *candidate)
 {
@@ -40,7 +43,10 @@ counter_is_valid(const char *candidate)
 static void
 print_counter(const char *iface, const char *name, const char *value)
 {
-	fprintf(stdout, "%s: %s\n", name, value);
+	if (show_label)
+		fprintf(stdout, "%s: %s\n", name, value);
+	else
+		fprintf(stdout, "%s\n", value);
 }
 
 static int
@@ -81,6 +87,17 @@ ifctrstat_list_counters(int short_opt, const struct if_option *opt, const char *
 	exit(EXIT_SUCCESS);
 }
 
+void
+ifctrstat_set_nolabel(int short_opt, const struct if_option *opt, const char *opt_arg, const struct if_applet *applet)
+{
+	(void) short_opt;
+	(void) opt;
+	(void) opt_arg;
+	(void) applet;
+
+	show_label = false;
+}
+
 int
 ifctrstat_main(int argc, char *argv[])
 {
@@ -125,7 +142,8 @@ ifctrstat_main(int argc, char *argv[])
 }
 
 static struct if_option local_options[] = {
-	{'L', "list", NULL, "List available counters", false, ifctrstat_list_counters}
+	{'L', "list", NULL, "List available counters", false, ifctrstat_list_counters},
+	{'n', "no-label", NULL, "Print value without counter label", false, ifctrstat_set_nolabel}
 };
 
 static struct if_option_group local_option_group = {