FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
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 __table_h__
25 #define __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 {
66 
67 typedef struct
68 {
70  u8 *text;
71 } table_cell_t;
72 
73 typedef struct
74 {
75  u8 no_ansi : 1;
78  int *row_sizes;
82 } table_t;
83 
85 
86 void table_format_title (table_t *t, char *fmt, ...);
87 void table_format_cell (table_t *t, int c, int r, char *fmt, ...);
88 void table_set_cell_align (table_t *t, int c, int r,
90 void table_set_cell_fg_color (table_t *t, int c, int r,
92 void table_set_cell_bg_color (table_t *t, int c, int r,
94 void table_free (table_t *t);
95 void table_add_header_col (table_t *t, int n_strings, ...);
96 void table_add_header_row (table_t *t, int n_strings, ...);
97 
98 #endif
table_free
void table_free(table_t *t)
Definition: table.c:221
TTAC_BLACK
@ TTAC_BLACK
Definition: table.h:41
table_add_header_row
void table_add_header_row(table_t *t, int n_strings,...)
Definition: table.c:258
TTAA_RIGHT
@ TTAA_RIGHT
Definition: table.h:55
TTAA_LEFT
@ TTAA_LEFT
Definition: table.h:54
TTAC_MAGENTA
@ TTAC_MAGENTA
Definition: table.h:46
TTAC_WHITE
@ TTAC_WHITE
Definition: table.h:48
TTAC_BLUE
@ TTAC_BLUE
Definition: table.h:45
table_text_attr_t::align
table_text_attr_align_t align
Definition: table.h:64
table_t::no_ansi
u8 no_ansi
Definition: table.h:75
table_text_attr_t::fg_color
table_text_attr_color_t fg_color
Definition: table.h:62
TTAF_RESET
@ TTAF_RESET
Definition: table.h:29
r
vnet_hw_if_output_node_runtime_t * r
Definition: interface_output.c:1071
table_t::title
u8 * title
Definition: table.h:76
table_format_title
void table_format_title(table_t *t, char *fmt,...)
Definition: table.c:158
TTAF_FG_COLOR_SET
@ TTAF_FG_COLOR_SET
Definition: table.h:33
TTAF_DIM
@ TTAF_DIM
Definition: table.h:31
TTAC_GREEN
@ TTAC_GREEN
Definition: table.h:43
table_t::n_header_rows
int n_header_rows
Definition: table.h:80
table_cell_t::attr
table_text_attr_t attr
Definition: table.h:69
TTAF_FG_COLOR_BRIGHT
@ TTAF_FG_COLOR_BRIGHT
Definition: table.h:35
table_text_attr_color_t
table_text_attr_color_t
Definition: table.h:39
c
svmdb_client_t * c
Definition: vpp_get_metrics.c:48
TTAF_BG_COLOR_BRIGHT
@ TTAF_BG_COLOR_BRIGHT
Definition: table.h:36
TTAC_YELLOW
@ TTAC_YELLOW
Definition: table.h:44
TTAF_BOLD
@ TTAF_BOLD
Definition: table.h:30
TTAF_BG_COLOR_SET
@ TTAF_BG_COLOR_SET
Definition: table.h:34
table_cell_t::text
u8 * text
Definition: table.h:70
fmt
int cJSON_bool fmt
Definition: cJSON.h:160
table_text_attr_flags_t
table_text_attr_flags_t
Definition: table.h:27
table_add_header_col
void table_add_header_col(table_t *t, int n_strings,...)
Definition: table.c:236
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
table_t::n_header_cols
int n_header_cols
Definition: table.h:79
table_t::n_footer_cols
int n_footer_cols
Definition: table.h:81
table_t
Definition: table.h:73
table_cell_t
Definition: table.h:67
table_set_cell_fg_color
void table_set_cell_fg_color(table_t *t, int c, int r, table_text_attr_color_t v)
Definition: table.c:205
TTAC_CYAN
@ TTAC_CYAN
Definition: table.h:47
table_format_cell
void table_format_cell(table_t *t, int c, int r, char *fmt,...)
Definition: table.c:181
TTAA_DEFAULT
@ TTAA_DEFAULT
Definition: table.h:53
table_set_cell_align
void table_set_cell_align(table_t *t, int c, int r, table_text_attr_align_t a)
Definition: table.c:198
TTAA_CENTER
@ TTAA_CENTER
Definition: table.h:56
u8
unsigned char u8
Definition: types.h:56
a
a
Definition: bitmap.h:544
TTAC_RED
@ TTAC_RED
Definition: table.h:42
table_t::row_sizes
int * row_sizes
Definition: table.h:78
table_text_attr_t::bg_color
table_text_attr_color_t bg_color
Definition: table.h:63
format_table
format_function_t format_table
Definition: table.h:84
table_t::cells
table_cell_t ** cells
Definition: table.h:77
table_text_attr_t::flags
table_text_attr_flags_t flags
Definition: table.h:61
TTAF_UNDERLINE
@ TTAF_UNDERLINE
Definition: table.h:32
table_text_attr_t
Definition: table.h:59
table_set_cell_bg_color
void table_set_cell_bg_color(table_t *t, int c, int r, table_text_attr_color_t v)
Definition: table.c:213
table_text_attr_align_t
table_text_attr_align_t
Definition: table.h:51