summaryrefslogtreecommitdiff
path: root/src/timedate
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-04-27 14:22:34 +0900
committerLennart Poettering <lennart@poettering.net>2021-04-28 17:36:09 +0200
commit255b1fc8a3055a7d59946a0fc483ee3885740398 (patch)
tree7c7d5ee14440f44c5fcbc548c9e8953e8834f8a5 /src/timedate
parentfeb10c665f8cdd8bd1cc12a4584910ad702c1b5a (diff)
downloadsystemd-255b1fc8a3055a7d59946a0fc483ee3885740398.tar.gz
bus-print-property: introduce BusPrintPropertyFlags
Follow-ups for 1ceaad69378272c64da4ecaab0d59ebb7a92ca0a.
Diffstat (limited to 'src/timedate')
-rw-r--r--src/timedate/timedatectl.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 4cab8acbd9..d31f67f4cb 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -34,8 +34,7 @@ static char *arg_host = NULL;
static bool arg_adjust_system_clock = false;
static bool arg_monitor = false;
static char **arg_property = NULL;
-static bool arg_value = false;
-static bool arg_all = false;
+static BusPrintPropertyFlags arg_print_flags = 0;
typedef struct StatusInfo {
usec_t time;
@@ -210,8 +209,7 @@ static int show_properties(int argc, char **argv, void *userdata) {
"/org/freedesktop/timedate1",
NULL,
arg_property,
- arg_value,
- arg_all,
+ arg_print_flags,
NULL);
if (r < 0)
return bus_log_parse_error(r);
@@ -702,7 +700,7 @@ static int show_timesync_status(int argc, char **argv, void *userdata) {
return 0;
}
-static int print_timesync_property(const char *name, const char *expected_value, sd_bus_message *m, bool value, bool all) {
+static int print_timesync_property(const char *name, const char *expected_value, sd_bus_message *m, BusPrintPropertyFlags flags) {
char type;
const char *contents;
int r;
@@ -728,7 +726,7 @@ static int print_timesync_property(const char *name, const char *expected_value,
if (i.packet_count == 0)
return 1;
- if (!value) {
+ if (!FLAGS_SET(flags, BUS_PRINT_PROPERTY_ONLY_VALUE)) {
fputs(name, stdout);
fputc('=', stdout);
}
@@ -767,8 +765,7 @@ static int print_timesync_property(const char *name, const char *expected_value,
if (r < 0)
return r;
- if (arg_all || !isempty(str))
- bus_print_property_value(name, expected_value, value, str);
+ bus_print_property_value(name, expected_value, flags, str);
return 1;
}
@@ -789,8 +786,7 @@ static int show_timesync(int argc, char **argv, void *userdata) {
"/org/freedesktop/timesync1",
print_timesync_property,
arg_property,
- arg_value,
- arg_all,
+ arg_print_flags,
NULL);
if (r < 0)
return bus_log_parse_error(r);
@@ -997,16 +993,16 @@ static int parse_argv(int argc, char *argv[]) {
/* If the user asked for a particular
* property, show it to them, even if it is
* empty. */
- arg_all = true;
+ SET_FLAG(arg_print_flags, BUS_PRINT_PROPERTY_SHOW_EMPTY, true);
break;
}
case 'a':
- arg_all = true;
+ SET_FLAG(arg_print_flags, BUS_PRINT_PROPERTY_SHOW_EMPTY, true);
break;
case ARG_VALUE:
- arg_value = true;
+ SET_FLAG(arg_print_flags, BUS_PRINT_PROPERTY_ONLY_VALUE, true);
break;
case '?':