X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fhostname%2Fhostnamectl.c;h=d8657fa4dd76e0d6820aeee5e2b96d9e129473ad;hb=84f6181c2ac99a0514ca5e0c8fc8c8e284caf789;hp=7591d99988759c7d0873d8697b43d2c4677eef3c;hpb=b028f3e410a7b9ba6b6291a79164d3de2638eb0b;p=elogind.git diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c index 7591d9998..d8657fa4d 100644 --- a/src/hostname/hostnamectl.c +++ b/src/hostname/hostnamectl.c @@ -142,12 +142,12 @@ static int show_one_name(sd_bus *bus, const char* attr) { static int show_all_names(sd_bus *bus) { StatusInfo info = {}; - const struct bus_properties_map map[] = { - { "s", "Hostname", &info.hostname }, - { "s", "StaticHostname", &info.static_hostname }, - { "s", "PrettyHostname", &info.pretty_hostname }, - { "s", "IconName", &info.icon_name }, - { "s", "Chassis", &info.chassis }, + static const struct bus_properties_map map[] = { + { "Hostname", "s", NULL, offsetof(StatusInfo, hostname) }, + { "StaticHostname", "s", NULL, offsetof(StatusInfo, static_hostname) }, + { "PrettyHostname", "s", NULL, offsetof(StatusInfo, pretty_hostname) }, + { "IconName", "s", NULL, offsetof(StatusInfo, icon_name) }, + { "Chassis", "s", NULL, offsetof(StatusInfo, chassis) }, {} }; int r; @@ -155,7 +155,8 @@ static int show_all_names(sd_bus *bus) { r = bus_map_all_properties(bus, "org.freedesktop.hostname1", "/org/freedesktop/hostname1", - map); + map, + &info); if (r < 0) goto fail; @@ -327,7 +328,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hHM:P", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0) { switch (c) { @@ -457,8 +458,8 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) { } int main(int argc, char *argv[]) { - int r; _cleanup_bus_unref_ sd_bus *bus = NULL; + int r; setlocale(LC_ALL, ""); log_parse_environment();