valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone
4bff0a
From c4f60df10a2716c94d30462a118f60d916d537a2 Mon Sep 17 00:00:00 2001
4bff0a
From: Lennart Poettering <lennart@poettering.net>
4bff0a
Date: Fri, 9 Nov 2018 11:38:12 +0100
4bff0a
Subject: [PATCH] format-table: add calls to query the data in a specific cell
4bff0a
4bff0a
(cherry picked from commit 62d99b39709f903f8a66a9aae757deb5546a53eb)
4bff0a
4bff0a
Related: #1689832
4bff0a
---
4bff0a
 src/basic/format-table.c | 22 ++++++++++++++++++++++
4bff0a
 src/basic/format-table.h |  3 +++
4bff0a
 2 files changed, 25 insertions(+)
4bff0a
4bff0a
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
4bff0a
index 3fcb97475c..0a1777e9a2 100644
4bff0a
--- a/src/basic/format-table.c
4bff0a
+++ b/src/basic/format-table.c
4bff0a
@@ -1438,3 +1438,25 @@ TableCell *table_get_cell(Table *t, size_t row, size_t column) {
4bff0a
 
4bff0a
         return TABLE_INDEX_TO_CELL(i);
4bff0a
 }
4bff0a
+
4bff0a
+const void *table_get(Table *t, TableCell *cell) {
4bff0a
+        TableData *d;
4bff0a
+
4bff0a
+        assert(t);
4bff0a
+
4bff0a
+        d = table_get_data(t, cell);
4bff0a
+        if (!d)
4bff0a
+                return NULL;
4bff0a
+
4bff0a
+        return d->data;
4bff0a
+}
4bff0a
+
4bff0a
+const void* table_get_at(Table *t, size_t row, size_t column) {
4bff0a
+        TableCell *cell;
4bff0a
+
4bff0a
+        cell = table_get_cell(t, row, column);
4bff0a
+        if (!cell)
4bff0a
+                return NULL;
4bff0a
+
4bff0a
+        return table_get(t, cell);
4bff0a
+}
4bff0a
diff --git a/src/basic/format-table.h b/src/basic/format-table.h
4bff0a
index 40fea79f78..a2bb2e0846 100644
4bff0a
--- a/src/basic/format-table.h
4bff0a
+++ b/src/basic/format-table.h
4bff0a
@@ -68,3 +68,6 @@ size_t table_get_rows(Table *t);
4bff0a
 size_t table_get_columns(Table *t);
4bff0a
 
4bff0a
 TableCell *table_get_cell(Table *t, size_t row, size_t column);
4bff0a
+
4bff0a
+const void *table_get(Table *t, TableCell *cell);
4bff0a
+const void *table_get_at(Table *t, size_t row, size_t column);