From: Lennart Poettering Date: Thu, 8 Nov 2018 20:21:09 +0000 (+0100) Subject: format-table: add an API for getting the cell at a specific row/column X-Git-Tag: v240~167^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9314ead7853a1479fc60eb2ae7e3d0a77b7eba7c;p=thirdparty%2Fsystemd.git format-table: add an API for getting the cell at a specific row/column --- diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 9b9796a6255..5292843acb5 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -1370,3 +1370,18 @@ int table_set_reverse(Table *t, size_t column, bool b) { t->reverse_map[column] = b; return 0; } + +TableCell *table_get_cell(Table *t, size_t row, size_t column) { + size_t i; + + assert(t); + + if (column >= t->n_columns) + return NULL; + + i = row * t->n_columns + column; + if (i >= t->n_cells) + return NULL; + + return TABLE_INDEX_TO_CELL(i); +} diff --git a/src/shared/format-table.h b/src/shared/format-table.h index 4273c8c49b9..40fea79f787 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -66,3 +66,5 @@ static inline TableCell* TABLE_HEADER_CELL(size_t i) { size_t table_get_rows(Table *t); size_t table_get_columns(Table *t); + +TableCell *table_get_cell(Table *t, size_t row, size_t column);