chiark / gitweb /
clients: various simplifications
[elogind.git] / src / hostname / hostnamectl.c
index 7591d99988759c7d0873d8697b43d2c4677eef3c..d8657fa4dd76e0d6820aeee5e2b96d9e129473ad 100644 (file)
@@ -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();