mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 07:51:21 +03:00
format-table: add cell type for outputting 64bit values in hex
This commit is contained in:
parent
bc773fcb35
commit
21fbf095b8
@ -272,6 +272,7 @@ static size_t table_data_size(TableDataType type, const void *data) {
|
|||||||
case TABLE_SIZE:
|
case TABLE_SIZE:
|
||||||
case TABLE_INT64:
|
case TABLE_INT64:
|
||||||
case TABLE_UINT64:
|
case TABLE_UINT64:
|
||||||
|
case TABLE_UINT64_HEX:
|
||||||
case TABLE_BPS:
|
case TABLE_BPS:
|
||||||
return sizeof(uint64_t);
|
return sizeof(uint64_t);
|
||||||
|
|
||||||
@ -922,6 +923,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TABLE_UINT64:
|
case TABLE_UINT64:
|
||||||
|
case TABLE_UINT64_HEX:
|
||||||
buffer.uint64 = va_arg(ap, uint64_t);
|
buffer.uint64 = va_arg(ap, uint64_t);
|
||||||
data = &buffer.uint64;
|
data = &buffer.uint64;
|
||||||
break;
|
break;
|
||||||
@ -1257,6 +1259,7 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
|
|||||||
return CMP(a->uint32, b->uint32);
|
return CMP(a->uint32, b->uint32);
|
||||||
|
|
||||||
case TABLE_UINT64:
|
case TABLE_UINT64:
|
||||||
|
case TABLE_UINT64_HEX:
|
||||||
return CMP(a->uint64, b->uint64);
|
return CMP(a->uint64, b->uint64);
|
||||||
|
|
||||||
case TABLE_PERCENT:
|
case TABLE_PERCENT:
|
||||||
@ -1608,6 +1611,18 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case TABLE_UINT64_HEX: {
|
||||||
|
_cleanup_free_ char *p;
|
||||||
|
|
||||||
|
p = new(char, 16 + 1);
|
||||||
|
if (!p)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
sprintf(p, "%" PRIx64, d->uint64);
|
||||||
|
d->formatted = TAKE_PTR(p);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TABLE_PERCENT: {
|
case TABLE_PERCENT: {
|
||||||
_cleanup_free_ char *p = NULL;
|
_cleanup_free_ char *p = NULL;
|
||||||
|
|
||||||
@ -2503,6 +2518,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
|
|||||||
return json_variant_new_unsigned(ret, d->uint32);
|
return json_variant_new_unsigned(ret, d->uint32);
|
||||||
|
|
||||||
case TABLE_UINT64:
|
case TABLE_UINT64:
|
||||||
|
case TABLE_UINT64_HEX:
|
||||||
return json_variant_new_unsigned(ret, d->uint64);
|
return json_variant_new_unsigned(ret, d->uint64);
|
||||||
|
|
||||||
case TABLE_PERCENT:
|
case TABLE_PERCENT:
|
||||||
|
@ -33,6 +33,7 @@ typedef enum TableDataType {
|
|||||||
TABLE_UINT16,
|
TABLE_UINT16,
|
||||||
TABLE_UINT32,
|
TABLE_UINT32,
|
||||||
TABLE_UINT64,
|
TABLE_UINT64,
|
||||||
|
TABLE_UINT64_HEX,
|
||||||
TABLE_PERCENT,
|
TABLE_PERCENT,
|
||||||
TABLE_IFINDEX,
|
TABLE_IFINDEX,
|
||||||
TABLE_IN_ADDR, /* Takes a union in_addr_union (or a struct in_addr) */
|
TABLE_IN_ADDR, /* Takes a union in_addr_union (or a struct in_addr) */
|
||||||
|
Loading…
Reference in New Issue
Block a user