From 0d088e48b5e4480fe2421bb90d601131bed35c8a Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Tue, 19 Nov 2024 01:13:47 +0100 Subject: Update format --- src/blocks/fs.c | 20 ++++++++++---------- src/blocks/ram.c | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/blocks') diff --git a/src/blocks/fs.c b/src/blocks/fs.c index 9c0a50c..188f14a 100644 --- a/src/blocks/fs.c +++ b/src/blocks/fs.c @@ -25,13 +25,13 @@ typedef enum { FS_USED_PERC, } block_fs_mark_t; -static const format_pair_t block_fs_pairs[] = { - { "total", FS_TOTAL }, - { "free", FS_FREE }, - { "used", FS_USED }, - { "free-percentage", FS_FREE_PERC }, - { "used-percentage", FS_USED_PERC }, - { NULL }, +static const format_option_t block_fs_options[] = { + { { "total", FS_TOTAL } }, + { { "free", FS_FREE } }, + { { "used", FS_USED } }, + { { "free-percentage", FS_FREE_PERC } }, + { { "used-percentage", FS_USED_PERC } }, + { { NULL } }, }; static const struct timespec block_fs_interval = { @@ -59,9 +59,9 @@ static void block_fs_update(block_t *block) size_t rest = start >= size ? 0 : size - start; if (rest == 0) break; - switch (fs->format.marks[i]) { + switch (fs->format.parts[i].mark) { case FS_STRING: - start += snprintf(buffer + start, rest, "%s", fs->format.parts[i]); + start += snprintf(buffer + start, rest, "%s", fs->format.parts[i].string); break; case FS_TOTAL: start += snprintf(buffer + start, rest, "%ld", sbuf.f_bsize * (uint64_t)sbuf.f_blocks); @@ -124,7 +124,7 @@ static bool block_fs_validate(block_t *block, const block_scheme_t *scheme) return false; } - int marked = format_remark(&fs->format, block->label, block_fs_pairs); + int marked = format_remark(&fs->format, block->label, block_fs_options); if (marked < 0) return false; diff --git a/src/blocks/ram.c b/src/blocks/ram.c index 0536c26..4841860 100644 --- a/src/blocks/ram.c +++ b/src/blocks/ram.c @@ -21,13 +21,13 @@ typedef enum { RAM_USED_PERC, } block_ram_mark_t; -static const format_pair_t block_ram_pairs[] = { - { "total", RAM_TOTAL }, - { "free", RAM_FREE }, - { "used", RAM_USED }, - { "free-percentage", RAM_FREE_PERC }, - { "used-percentage", RAM_USED_PERC }, - { NULL }, +static const format_option_t block_ram_options[] = { + { { "total", RAM_TOTAL } }, + { { "free", RAM_FREE } }, + { { "used", RAM_USED } }, + { { "free-percentage", RAM_FREE_PERC } }, + { { "used-percentage", RAM_USED_PERC } }, + { { NULL } }, }; static const struct timespec block_ram_interval = { @@ -74,9 +74,9 @@ static void block_ram_update(block_t *block) size_t rest = start >= size ? 0 : size - start; if (rest == 0) break; - switch (ram->format.marks[i]) { + switch (ram->format.parts[i].mark) { case RAM_STRING: - start += snprintf(buffer + start, rest, "%s", ram->format.parts[i]); + start += snprintf(buffer + start, rest, "%s", ram->format.parts[i].string); break; case RAM_TOTAL: start += snprintf(buffer + start, rest, "%ld", total); @@ -138,7 +138,7 @@ static bool block_ram_validate(block_t *block, const block_scheme_t *scheme) return false; } - int marked = format_remark(&ram->format, block->label, block_ram_pairs); + int marked = format_remark(&ram->format, block->label, block_ram_options); if (marked < 0) return false; -- cgit v1.2.3