|
Last change
on this file since d7f7a4a was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago |
|
Replace some license headers with SPDX identifier
Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.
|
-
Property mode
set to
100644
|
|
File size:
1.8 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2017 Jiri Svoboda
|
|---|
| 3 | *
|
|---|
| 4 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 5 | */
|
|---|
| 6 |
|
|---|
| 7 | /** @addtogroup libc
|
|---|
| 8 | * @{
|
|---|
| 9 | */
|
|---|
| 10 | /** @file
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #ifndef _LIBC_IO_TABLE_H_
|
|---|
| 14 | #define _LIBC_IO_TABLE_H_
|
|---|
| 15 |
|
|---|
| 16 | #include <adt/list.h>
|
|---|
| 17 | #include <stdbool.h>
|
|---|
| 18 | #include <stddef.h>
|
|---|
| 19 | #include <stdio.h>
|
|---|
| 20 | #include <errno.h>
|
|---|
| 21 |
|
|---|
| 22 | /** Table metrics */
|
|---|
| 23 | typedef struct {
|
|---|
| 24 | /** Space to the left of the table */
|
|---|
| 25 | size_t margin_left;
|
|---|
| 26 | } table_metrics_t;
|
|---|
| 27 |
|
|---|
| 28 | /** Table cell */
|
|---|
| 29 | typedef struct {
|
|---|
| 30 | /** Containing row */
|
|---|
| 31 | struct table_row *row;
|
|---|
| 32 | /** Link to table_row_t.cells */
|
|---|
| 33 | link_t lrow;
|
|---|
| 34 | /** Cell text */
|
|---|
| 35 | char *text;
|
|---|
| 36 | } table_cell_t;
|
|---|
| 37 |
|
|---|
| 38 | /** Table row */
|
|---|
| 39 | typedef struct table_row {
|
|---|
| 40 | /** Containing table */
|
|---|
| 41 | struct table *table;
|
|---|
| 42 | /** Link to table_t.rows */
|
|---|
| 43 | link_t ltable;
|
|---|
| 44 | /** Cells of this row */
|
|---|
| 45 | list_t cells;
|
|---|
| 46 | } table_row_t;
|
|---|
| 47 |
|
|---|
| 48 | /** Table column */
|
|---|
| 49 | typedef struct {
|
|---|
| 50 | /** Containing table */
|
|---|
| 51 | struct table *table;
|
|---|
| 52 | /** Link to table_t.columns */
|
|---|
| 53 | link_t ltable;
|
|---|
| 54 | /** Column width */
|
|---|
| 55 | size_t width;
|
|---|
| 56 | } table_column_t;
|
|---|
| 57 |
|
|---|
| 58 | /** Table */
|
|---|
| 59 | typedef struct table {
|
|---|
| 60 | /** @c true if the first row is a header row */
|
|---|
| 61 | bool header_row;
|
|---|
| 62 | /** Encountered error while writing to table */
|
|---|
| 63 | errno_t error;
|
|---|
| 64 | /** Table rows */
|
|---|
| 65 | list_t rows; /* of table_row_t */
|
|---|
| 66 | /** Table columns */
|
|---|
| 67 | list_t columns; /* of table_column_t */
|
|---|
| 68 | /** Current row */
|
|---|
| 69 | table_row_t *wrow;
|
|---|
| 70 | /** Current cell */
|
|---|
| 71 | table_cell_t *wcell;
|
|---|
| 72 | /** Current column */
|
|---|
| 73 | table_column_t *wcolumn;
|
|---|
| 74 | /** Table metrics */
|
|---|
| 75 | table_metrics_t metrics;
|
|---|
| 76 | } table_t;
|
|---|
| 77 |
|
|---|
| 78 | extern errno_t table_create(table_t **);
|
|---|
| 79 | extern void table_destroy(table_t *);
|
|---|
| 80 | extern errno_t table_print_out(table_t *, FILE *);
|
|---|
| 81 | extern void table_header_row(table_t *);
|
|---|
| 82 | extern errno_t table_printf(table_t *, const char *, ...);
|
|---|
| 83 | extern errno_t table_get_error(table_t *);
|
|---|
| 84 | extern void table_set_margin_left(table_t *, size_t);
|
|---|
| 85 |
|
|---|
| 86 | #endif
|
|---|
| 87 |
|
|---|
| 88 | /** @}
|
|---|
| 89 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.