]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/shared/format-table.h
table: add TABLE_UINT8 or friends
[thirdparty/systemd.git] / src / shared / format-table.h
index 5ff247953b5f2cb653812c8c421fe2c1d9f3d145..c6df8bf70cbda0958e1bd07878d26cdff4a2e181 100644 (file)
@@ -13,12 +13,39 @@ typedef enum TableDataType {
         TABLE_STRING,
         TABLE_BOOLEAN,
         TABLE_TIMESTAMP,
+        TABLE_TIMESTAMP_UTC,
+        TABLE_TIMESTAMP_RELATIVE,
         TABLE_TIMESPAN,
+        TABLE_TIMESPAN_MSEC,
         TABLE_SIZE,
+        TABLE_BPS,
+        TABLE_INT,
+        TABLE_INT8,
+        TABLE_INT16,
+        TABLE_INT32,
+        TABLE_INT64,
+        TABLE_UINT,
+        TABLE_UINT8,
+        TABLE_UINT16,
         TABLE_UINT32,
         TABLE_UINT64,
         TABLE_PERCENT,
+        TABLE_IFINDEX,
+        TABLE_IN_ADDR,  /* Takes a union in_addr_union (or a struct in_addr) */
+        TABLE_IN6_ADDR, /* Takes a union in_addr_union (or a struct in6_addr) */
         _TABLE_DATA_TYPE_MAX,
+
+        /* The following are not really data types, but commands for table_add_cell_many() to make changes to
+         * a cell just added. */
+        TABLE_SET_MINIMUM_WIDTH,
+        TABLE_SET_MAXIMUM_WIDTH,
+        TABLE_SET_WEIGHT,
+        TABLE_SET_ALIGN_PERCENT,
+        TABLE_SET_ELLIPSIZE_PERCENT,
+        TABLE_SET_COLOR,
+        TABLE_SET_URL,
+        TABLE_SET_UPPERCASE,
+
         _TABLE_DATA_TYPE_INVALID = -1,
 } TableDataType;
 
@@ -36,6 +63,7 @@ int table_add_cell_full(Table *t, TableCell **ret_cell, TableDataType type, cons
 static inline int table_add_cell(Table *t, TableCell **ret_cell, TableDataType type, const void *data) {
         return table_add_cell_full(t, ret_cell, type, data, (size_t) -1, (size_t) -1, (unsigned) -1, (unsigned) -1, (unsigned) -1);
 }
+int table_add_cell_stringf(Table *t, TableCell **ret_cell, const char *format, ...) _printf_(3, 4);
 
 int table_dup_cell(Table *t, TableCell *cell);
 
@@ -45,7 +73,7 @@ int table_set_weight(Table *t, TableCell *cell, unsigned weight);
 int table_set_align_percent(Table *t, TableCell *cell, unsigned percent);
 int table_set_ellipsize_percent(Table *t, TableCell *cell, unsigned percent);
 int table_set_color(Table *t, TableCell *cell, const char *color);
-int table_set_url(Table *t, TableCell *cell, const char *color);
+int table_set_url(Table *t, TableCell *cell, const char *url);
 int table_set_uppercase(Table *t, TableCell *cell, bool b);
 
 int table_update(Table *t, TableCell *cell, TableDataType type, const void *data);
@@ -75,4 +103,4 @@ const void *table_get(Table *t, TableCell *cell);
 const void *table_get_at(Table *t, size_t row, size_t column);
 
 int table_to_json(Table *t, JsonVariant **ret);
-int table_print_json(Table *t, FILE *f, unsigned json_flags);
+int table_print_json(Table *t, FILE *f, JsonFormatFlags json_flags);