]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
format-table: introduce TABLE_PATH
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Jan 2020 11:14:30 +0000 (20:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 9 Jan 2020 11:16:03 +0000 (20:16 +0900)
src/shared/format-table.c
src/shared/format-table.h

index 4617ae8badc43728d6c4317190d960aa08365bd3..47d56dd085baf3676025c3c3cce28f4f7c431684 100644 (file)
@@ -14,6 +14,7 @@
 #include "memory-util.h"
 #include "pager.h"
 #include "parse-util.h"
+#include "path-util.h"
 #include "pretty-print.h"
 #include "sort-util.h"
 #include "string-util.h"
@@ -234,6 +235,7 @@ static size_t table_data_size(TableDataType type, const void *data) {
                 return 0;
 
         case TABLE_STRING:
+        case TABLE_PATH:
                 return strlen(data) + 1;
 
         case TABLE_BOOLEAN:
@@ -768,6 +770,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
                         break;
 
                 case TABLE_STRING:
+                case TABLE_PATH:
                         data = va_arg(ap, const char *);
                         break;
 
@@ -1038,6 +1041,9 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
                 case TABLE_STRING:
                         return strcmp(a->string, b->string);
 
+                case TABLE_PATH:
+                        return path_compare(a->string, b->string);
+
                 case TABLE_BOOLEAN:
                         if (!a->boolean && b->boolean)
                                 return -1;
@@ -1151,6 +1157,7 @@ static const char *table_data_format(Table *t, TableData *d) {
                 return strempty(t->empty_string);
 
         case TABLE_STRING:
+        case TABLE_PATH:
                 if (d->uppercase) {
                         char *p, *q;
 
@@ -1897,6 +1904,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
                 return json_variant_new_null(ret);
 
         case TABLE_STRING:
+        case TABLE_PATH:
                 return json_variant_new_string(ret, d->string);
 
         case TABLE_BOOLEAN:
index 80f319d054a30bf5f81c48ced3bccd05ce89e4fd..b23e4de99d0f6c13144f1c52850c75e37c90be98 100644 (file)
@@ -11,6 +11,7 @@
 typedef enum TableDataType {
         TABLE_EMPTY,
         TABLE_STRING,
+        TABLE_PATH,
         TABLE_BOOLEAN,
         TABLE_TIMESTAMP,
         TABLE_TIMESTAMP_UTC,