vppinfra: move format_table from perfmon 46/33746/2
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Fri, 17 Sep 2021 09:51:46 +0000 (11:51 +0200)
committerDamjan Marion <dmarion@me.com>
Fri, 17 Sep 2021 20:10:59 +0000 (20:10 +0000)
This code seems really usefull for reuse in
other plugins, for pretty table formatting

Type: feature

Change-Id: Ib5784a0dfc81b7d5a5d1f5ccdd02072e460a50fb
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/plugins/perfmon/CMakeLists.txt
src/plugins/perfmon/cli.c
src/vppinfra/CMakeLists.txt
src/vppinfra/format_table.c [moved from src/plugins/perfmon/table.c with 99% similarity]
src/vppinfra/format_table.h [moved from src/plugins/perfmon/table.h with 73% similarity]

index e2f8888..060c425 100644 (file)
@@ -21,7 +21,6 @@ add_vpp_plugin(perfmon
   dispatch_wrapper.c
   linux.c
   perfmon.c
-  table.c
   intel/core.c
   intel/uncore.c
   intel/bundle/membw_bound.c
index ce191ea..2c0ff9e 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <vnet/vnet.h>
 #include <perfmon/perfmon.h>
-#include <perfmon/table.h>
+#include <vppinfra/format_table.h>
 
 uword
 unformat_perfmon_bundle_name (unformat_input_t *input, va_list *args)
index c682d70..8114ea1 100644 (file)
@@ -57,6 +57,7 @@ set(VPPINFRA_SRCS
   error.c
   fifo.c
   format.c
+  format_table.c
   graph.c
   hash.c
   heap.c
@@ -134,6 +135,7 @@ set(VPPINFRA_HEADERS
   fifo.h
   file.h
   format.h
+  format_table.h
   graph.h
   hash.h
   heap.h
similarity index 99%
rename from src/plugins/perfmon/table.c
rename to src/vppinfra/format_table.c
index e3fc098..5d83f7a 100644 (file)
@@ -22,7 +22,7 @@
 */
 
 #include <vppinfra/format.h>
-#include "table.h"
+#include <vppinfra/format_table.h>
 
 static table_text_attr_t default_title = {
   .flags = TTAF_FG_COLOR_SET | TTAF_BOLD,
similarity index 73%
rename from src/plugins/perfmon/table.h
rename to src/vppinfra/format_table.h
index 93102a0..f9b66a7 100644 (file)
@@ -21,8 +21,8 @@
   WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#ifndef __table_h__
-#define __table_h__
+#ifndef __format_table_h__
+#define __format_table_h__
 
 typedef enum
 {
@@ -81,18 +81,19 @@ typedef struct
   int n_footer_cols;
 } table_t;
 
-format_function_t format_table;
+__clib_export format_function_t format_table;
 
-void table_format_title (table_t *t, char *fmt, ...);
-void table_format_cell (table_t *t, int c, int r, char *fmt, ...);
-void table_set_cell_align (table_t *t, int c, int r,
-                          table_text_attr_align_t a);
-void table_set_cell_fg_color (table_t *t, int c, int r,
-                             table_text_attr_color_t v);
-void table_set_cell_bg_color (table_t *t, int c, int r,
-                             table_text_attr_color_t v);
-void table_free (table_t *t);
-void table_add_header_col (table_t *t, int n_strings, ...);
-void table_add_header_row (table_t *t, int n_strings, ...);
+__clib_export void table_format_title (table_t *t, char *fmt, ...);
+__clib_export void table_format_cell (table_t *t, int c, int r, char *fmt,
+                                     ...);
+__clib_export void table_set_cell_align (table_t *t, int c, int r,
+                                        table_text_attr_align_t a);
+__clib_export void table_set_cell_fg_color (table_t *t, int c, int r,
+                                           table_text_attr_color_t v);
+__clib_export void table_set_cell_bg_color (table_t *t, int c, int r,
+                                           table_text_attr_color_t v);
+__clib_export void table_free (table_t *t);
+__clib_export void table_add_header_col (table_t *t, int n_strings, ...);
+__clib_export void table_add_header_row (table_t *t, int n_strings, ...);
 
 #endif