]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
format-table: add an API for getting the cell at a specific row/column
authorLennart Poettering <lennart@poettering.net>
Thu, 8 Nov 2018 20:21:09 +0000 (21:21 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 30 Nov 2018 15:46:10 +0000 (16:46 +0100)
src/shared/format-table.c
src/shared/format-table.h

index 9b9796a6255da220de5cb3e34073f4d8badd280a..5292843acb5c86750d8acc7796343e1ac015b93e 100644 (file)
@@ -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);
+}
index 4273c8c49b9fc4c39c06c7fade9cd0b8f4919e57..40fea79f7879ed2ee768ec898bd0c7ba2df09da9 100644 (file)
@@ -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);