return bus_print_property_value(name, expected_value, flags, s);
}
-static int bus_print_property(const char *name, const char *expected_value, sd_bus_message *m, BusPrintPropertyFlags flags) {
- char type;
- const char *contents;
+static int bus_print_property(
+ const char *name,
+ const char *expected_value,
+ char type,
+ const char *contents,
+ sd_bus_message *m,
+ BusPrintPropertyFlags flags) {
+
int r;
assert(name);
assert(m);
- r = sd_bus_message_peek_type(m, &type, &contents);
- if (r < 0)
- return r;
-
switch (type) {
case SD_BUS_TYPE_STRING: {
if (r < 0)
return r;
+ char value_type;
+ const char *value_contents;
+ r = sd_bus_message_peek_type(m, &value_type, &value_contents);
+ if (r < 0)
+ return r;
+
if (func)
- r = func(name, expected_value, m, flags);
+ r = func(name, expected_value, value_type, value_contents, m, flags);
if (!func || r == 0)
- r = bus_print_property(name, expected_value, m, flags);
+ r = bus_print_property(name, expected_value, value_type, value_contents, m, flags);
if (r < 0)
return r;
if (r == 0) {
return 0;
}
-static int print_property(const char *name, const char *expected_value, sd_bus_message *m, BusPrintPropertyFlags flags) {
- char bus_type;
- const char *contents;
+static int print_property(
+ const char *name,
+ const char *expected_value,
+ char type,
+ const char *contents,
+ sd_bus_message *m,
+ BusPrintPropertyFlags flags) {
+
int r;
assert(name);
/* This is a low-level property printer, see print_status_info() for the nicer output */
- r = sd_bus_message_peek_type(m, &bus_type, &contents);
- if (r < 0)
- return r;
-
- switch (bus_type) {
+ switch (type) {
case SD_BUS_TYPE_INT32:
if (endswith(name, "ActionExitStatus")) {
int32_t i;
- r = sd_bus_message_read_basic(m, bus_type, &i);
+ r = sd_bus_message_read_basic(m, type, &i);
if (r < 0)
return r;
} else if (streq(name, "NUMAPolicy")) {
int32_t i;
- r = sd_bus_message_read_basic(m, bus_type, &i);
+ r = sd_bus_message_read_basic(m, type, &i);
if (r < 0)
return r;
if (bus_property_is_timestamp(name)) {
uint64_t timestamp;
- r = sd_bus_message_read_basic(m, bus_type, ×tamp);
+ r = sd_bus_message_read_basic(m, type, ×tamp);
if (r < 0)
return r;
return 1;
} else if (contents[0] == SD_BUS_TYPE_STRUCT_BEGIN && streq(name, "Paths")) {
- const char *type, *path;
+ const char *entry_type, *path;
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(ss)");
if (r < 0)
return bus_log_parse_error(r);
- while ((r = sd_bus_message_read(m, "(ss)", &type, &path)) > 0)
- bus_print_property_valuef(name, expected_value, flags, "%s (%s)", path, type);
+ while ((r = sd_bus_message_read(m, "(ss)", &entry_type, &path)) > 0)
+ bus_print_property_valuef(name, expected_value, flags, "%s (%s)", path, entry_type);
if (r < 0)
return bus_log_parse_error(r);
return 1;
} else if (contents[0] == SD_BUS_TYPE_STRUCT_BEGIN && streq(name, "Listen")) {
- const char *type, *path;
+ const char *entry_type, *path;
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "(ss)");
if (r < 0)
return bus_log_parse_error(r);
- while ((r = sd_bus_message_read(m, "(ss)", &type, &path)) > 0)
- bus_print_property_valuef(name, expected_value, flags, "%s (%s)", path, type);
+ while ((r = sd_bus_message_read(m, "(ss)", &entry_type, &path)) > 0)
+ bus_print_property_valuef(name, expected_value, flags, "%s (%s)", path, entry_type);
if (r < 0)
return bus_log_parse_error(r);