|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
A text file as LOGS shows it. See log_text.h. More...
Macros | |
| #define | MARKS ((LOG_TEXT_MAX / LOG_TEXT_MARK) + 1u) |
| Marks a text of LOG_TEXT_MAX rows takes: rows 0, MARK, 2 MARK, ... | |
Functions | |
| void | log_text_set_allocator (void *(*alloc_fn)(size_t), void(*free_fn)(void *)) |
| Set the allocator the buffer comes from, for a test that refuses it. | |
| void | log_text_free (log_text_t *t) |
Free what t holds and empty it. | |
| static size_t | row_at (log_text_t *t, size_t off, size_t *end) |
The row that starts at off: where it ends and where the next one starts. Counts the bytes it reads into walked. | |
| static size_t | whole (const char *buf, size_t len) |
The length of buf without a last character cut short. | |
| static size_t | read_text (log_source_t *src, char *buf, bool *cut) |
Read src into buf, LOG_TEXT_MAX bytes at most, with the line ends made LF and a tab or a NUL made a space. | |
| log_err_t | log_text_load (log_text_t *t, log_source_t *src, int cols) |
Read src from its top into t, and count its rows. | |
| bool | log_text_row (log_text_t *t, int i, char *out, size_t n) |
Row i of the text into out. | |
Variables | |
| static void *(*) | s_alloc (size_t) = malloc |
| Takes a text's buffer and marks (log_text_set_allocator()). | |
| static void(*) | s_free (void *) = free |
| Gives them back. | |
A text file as LOGS shows it. See log_text.h.
SPDX-License-Identifier: MIT
| void log_text_free | ( | log_text_t * | t | ) |
Free what t holds and empty it.
| t | the text; nothing happens for NULL |
| log_err_t log_text_load | ( | log_text_t * | t, |
| log_source_t * | src, | ||
| int | cols ) |
Read src from its top into t, and count its rows.
What t held before is freed first.
| t | the text; nothing happens for NULL |
| src | the file, read to its end or to LOG_TEXT_MAX bytes |
| cols | cells a row holds, 1 or more |
cols under 1; LOG_ERR_MEMORY when the buffers are not given; LOG_ERR_READ when a read fails. t holds nothing after a failure. | bool log_text_row | ( | log_text_t * | t, |
| int | i, | ||
| char * | out, | ||
| size_t | n ) |
Row i of the text into out.
| t | the text |
| i | the row, 0 to rows - 1 |
| out | takes the row, terminated; cut at n - 1 bytes, between two characters |
| n | bytes of out |
out empty | void log_text_set_allocator | ( | void * | alloc_fn (*)(size_t), |
| void(* | free_fn )(void *) ) |
Set the allocator the buffer comes from, for a test that refuses it.
| alloc_fn | NULL for malloc |
| free_fn | NULL for free |
|
static |
Read src into buf, LOG_TEXT_MAX bytes at most, with the line ends made LF and a tab or a NUL made a space.
| src | the file, read from where it stands |
| buf | takes the text; LOG_TEXT_MAX bytes and a terminator |
| cut | takes whether the file holds more |
buf
|
static |
The row that starts at off: where it ends and where the next one starts. Counts the bytes it reads into walked.
| t | the text, off inside it |
| off | the row's first byte |
| end | takes the byte after the row's last |
len after the last row
|
static |
The length of buf without a last character cut short.
| buf | UTF-8 text |
| len | its bytes |
len, or less by the bytes of a last character that misses some of its continuation bytes