FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
format_table.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2020 Damjan Marion
3 
4  Permission is hereby granted, free of charge, to any person obtaining
5  a copy of this software and associated documentation files (the
6  "Software"), to deal in the Software without restriction, including
7  without limitation the rights to use, copy, modify, merge, publish,
8  distribute, sublicense, and/or sell copies of the Software, and to
9  permit persons to whom the Software is furnished to do so, subject to
10  the following conditions:
11 
12  The above copyright notice and this permission notice shall be
13  included in all copies or substantial portions of the Software.
14 
15  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 
24 #ifndef __format_table_h__
25 #define __format_table_h__
26 
27 typedef enum
28 {
29  TTAF_RESET = (1 << 0),
30  TTAF_BOLD = (1 << 1),
31  TTAF_DIM = (1 << 2),
32  TTAF_UNDERLINE = (1 << 3),
33  TTAF_FG_COLOR_SET = (1 << 4),
34  TTAF_BG_COLOR_SET = (1 << 5),
38 
39 typedef enum
40 {
42  TTAC_RED = 1,
45  TTAC_BLUE = 4,
47  TTAC_CYAN = 6,
50 
51 typedef enum
52 {
54  TTAA_LEFT = 1,
58 
59 typedef struct
60 {
61  union
62  {
63  struct
64  {
69  };
71  };
73 
74 typedef struct
75 {
77  u8 *text;
78 } table_cell_t;
79 
80 typedef struct
81 {
82  u8 no_ansi : 1;
85  int *row_sizes;
93 } table_t;
94 
96 
97 __clib_export void table_format_title (table_t *t, char *fmt, ...);
98 __clib_export void table_format_cell (table_t *t, int c, int r, char *fmt,
99  ...);
100 __clib_export void table_set_cell_align (table_t *t, int c, int r,
102 __clib_export void table_set_cell_fg_color (table_t *t, int c, int r,
104 __clib_export void table_set_cell_bg_color (table_t *t, int c, int r,
106 __clib_export void table_free (table_t *t);
107 __clib_export void table_add_header_col (table_t *t, int n_strings, ...);
108 __clib_export void table_add_header_row (table_t *t, int n_strings, ...);
109 
110 #endif
TTAF_FG_COLOR_BRIGHT
@ TTAF_FG_COLOR_BRIGHT
Definition: format_table.h:35
TTAF_UNDERLINE
@ TTAF_UNDERLINE
Definition: format_table.h:32
TTAC_RED
@ TTAC_RED
Definition: format_table.h:42
TTAC_CYAN
@ TTAC_CYAN
Definition: format_table.h:47
table_text_attr_t::align
table_text_attr_align_t align
Definition: format_table.h:68
table_t::no_ansi
u8 no_ansi
Definition: format_table.h:82
table_text_attr_t::fg_color
table_text_attr_color_t fg_color
Definition: format_table.h:66
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1089
table_text_attr_align_t
table_text_attr_align_t
Definition: format_table.h:51
table_t::title
u8 * title
Definition: format_table.h:83
table_set_cell_align
__clib_export void table_set_cell_align(table_t *t, int c, int r, table_text_attr_align_t a)
Definition: format_table.c:209
TTAF_DIM
@ TTAF_DIM
Definition: format_table.h:31
TTAC_YELLOW
@ TTAC_YELLOW
Definition: format_table.h:44
table_t::default_header_col
table_text_attr_t default_header_col
Definition: format_table.h:91
TTAF_FG_COLOR_SET
@ TTAF_FG_COLOR_SET
Definition: format_table.h:33
TTAF_BOLD
@ TTAF_BOLD
Definition: format_table.h:30
table_text_attr_flags_t
table_text_attr_flags_t
Definition: format_table.h:27
TTAA_CENTER
@ TTAA_CENTER
Definition: format_table.h:56
table_t::n_header_rows
int n_header_rows
Definition: format_table.h:87
table_cell_t::attr
table_text_attr_t attr
Definition: format_table.h:76
TTAF_RESET
@ TTAF_RESET
Definition: format_table.h:29
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
table_set_cell_bg_color
__clib_export void table_set_cell_bg_color(table_t *t, int c, int r, table_text_attr_color_t v)
Definition: format_table.c:224
table_format_cell
__clib_export void table_format_cell(table_t *t, int c, int r, char *fmt,...)
Definition: format_table.c:192
table_t::default_title
table_text_attr_t default_title
Definition: format_table.h:89
table_text_attr_color_t
table_text_attr_color_t
Definition: format_table.h:39
format_table
__clib_export format_function_t format_table
Definition: format_table.h:95
TTAC_BLACK
@ TTAC_BLACK
Definition: format_table.h:41
TTAC_BLUE
@ TTAC_BLUE
Definition: format_table.h:45
TTAA_LEFT
@ TTAA_LEFT
Definition: format_table.h:54
TTAC_MAGENTA
@ TTAC_MAGENTA
Definition: format_table.h:46
table_cell_t::text
u8 * text
Definition: format_table.h:77
fmt
int cJSON_bool fmt
Definition: cJSON.h:160
table_add_header_row
__clib_export void table_add_header_row(table_t *t, int n_strings,...)
Definition: format_table.c:269
TTAA_RIGHT
@ TTAA_RIGHT
Definition: format_table.h:55
TTAF_BG_COLOR_BRIGHT
@ TTAF_BG_COLOR_BRIGHT
Definition: format_table.h:36
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
table_t::default_header_row
table_text_attr_t default_header_row
Definition: format_table.h:92
table_t::n_header_cols
int n_header_cols
Definition: format_table.h:86
table_t::n_footer_cols
int n_footer_cols
Definition: format_table.h:88
table_t
Definition: format_table.h:80
TTAC_GREEN
@ TTAC_GREEN
Definition: format_table.h:43
table_add_header_col
__clib_export void table_add_header_col(table_t *t, int n_strings,...)
Definition: format_table.c:247
table_cell_t
Definition: format_table.h:74
u32
unsigned int u32
Definition: types.h:88
TTAF_BG_COLOR_SET
@ TTAF_BG_COLOR_SET
Definition: format_table.h:34
TTAA_DEFAULT
@ TTAA_DEFAULT
Definition: format_table.h:53
table_free
__clib_export void table_free(table_t *t)
Definition: format_table.c:232
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:525
table_t::row_sizes
int * row_sizes
Definition: format_table.h:85
table_text_attr_t::as_u32
u32 as_u32
Definition: format_table.h:70
table_text_attr_t::bg_color
table_text_attr_color_t bg_color
Definition: format_table.h:67
table_set_cell_fg_color
__clib_export void table_set_cell_fg_color(table_t *t, int c, int r, table_text_attr_color_t v)
Definition: format_table.c:216
table_t::default_body
table_text_attr_t default_body
Definition: format_table.h:90
TTAC_WHITE
@ TTAC_WHITE
Definition: format_table.h:48
table_t::cells
table_cell_t ** cells
Definition: format_table.h:84
table_format_title
__clib_export void table_format_title(table_t *t, char *fmt,...)
Definition: format_table.c:169
table_text_attr_t::flags
table_text_attr_flags_t flags
Definition: format_table.h:65
table_text_attr_t
Definition: format_table.h:59