hostnamectl.c   hostnamectl.c 
skipping to change at line 70 skipping to change at line 70
polkit_agent_open(); polkit_agent_open();
} }
typedef struct StatusInfo { typedef struct StatusInfo {
char *hostname; char *hostname;
char *static_hostname; char *static_hostname;
char *pretty_hostname; char *pretty_hostname;
char *icon_name; char *icon_name;
char *chassis; char *chassis;
char *deployment;
char *location;
char *kernel_name; char *kernel_name;
char *kernel_release; char *kernel_release;
char *os_pretty_name; char *os_pretty_name;
char *os_cpe_name; char *os_cpe_name;
char *virtualization; char *virtualization;
char *architecture; char *architecture;
} StatusInfo; } StatusInfo;
static void print_status_info(StatusInfo *i) { static void print_status_info(StatusInfo *i) {
sd_id128_t mid = {}, bid = {}; sd_id128_t mid = {}, bid = {};
skipping to change at line 94 skipping to change at line 96
printf(" Static hostname: %s\n", strna(i->static_hostname)); printf(" Static hostname: %s\n", strna(i->static_hostname));
if (!isempty(i->pretty_hostname) && if (!isempty(i->pretty_hostname) &&
!streq_ptr(i->pretty_hostname, i->static_hostname)) !streq_ptr(i->pretty_hostname, i->static_hostname))
printf(" Pretty hostname: %s\n", i->pretty_hostname); printf(" Pretty hostname: %s\n", i->pretty_hostname);
if (!isempty(i->hostname) && if (!isempty(i->hostname) &&
!streq_ptr(i->hostname, i->static_hostname)) !streq_ptr(i->hostname, i->static_hostname))
printf("Transient hostname: %s\n", i->hostname); printf("Transient hostname: %s\n", i->hostname);
printf(" Icon name: %s\n" if (!isempty(i->icon_name))
" Chassis: %s\n", printf(" Icon name: %s\n",
strna(i->icon_name), strna(i->icon_name));
strna(i->chassis));
if (!isempty(i->chassis))
printf(" Chassis: %s\n",
strna(i->chassis));
if (!isempty(i->deployment))
printf(" Deployment: %s\n", i->deployment);
if (!isempty(i->location))
printf(" Location: %s\n", i->location);
r = sd_id128_get_machine(&mid); r = sd_id128_get_machine(&mid);
if (r >= 0) if (r >= 0)
printf(" Machine ID: " SD_ID128_FORMAT_STR "\n", SD_ ID128_FORMAT_VAL(mid)); printf(" Machine ID: " SD_ID128_FORMAT_STR "\n", SD_ ID128_FORMAT_VAL(mid));
r = sd_id128_get_boot(&bid); r = sd_id128_get_boot(&bid);
if (r >= 0) if (r >= 0)
printf(" Boot ID: " SD_ID128_FORMAT_STR "\n", SD_ ID128_FORMAT_VAL(bid)); printf(" Boot ID: " SD_ID128_FORMAT_STR "\n", SD_ ID128_FORMAT_VAL(bid));
if (!isempty(i->virtualization)) if (!isempty(i->virtualization))
skipping to change at line 155 skipping to change at line 166
printf("%s\n", s); printf("%s\n", s);
return 0; return 0;
} }
static int show_all_names(sd_bus *bus) { static int show_all_names(sd_bus *bus) {
StatusInfo info = {}; StatusInfo info = {};
static const struct bus_properties_map hostname_map[] = { static const struct bus_properties_map hostname_map[] = {
{ "Hostname", "s", NULL, offsetof(StatusInfo, hostnam { "Hostname", "s", NULL, offsetof(StatusIn
e) }, fo, hostname) },
{ "StaticHostname", "s", NULL, offsetof(StatusInfo, static_ { "StaticHostname", "s", NULL, offsetof(StatusIn
hostname) }, fo, static_hostname) },
{ "PrettyHostname", "s", NULL, offsetof(StatusInfo, pretty_ { "PrettyHostname", "s", NULL, offsetof(StatusIn
hostname) }, fo, pretty_hostname) },
{ "IconName", "s", NULL, offsetof(StatusInfo, icon_na { "IconName", "s", NULL, offsetof(StatusIn
me) }, fo, icon_name) },
{ "Chassis", "s", NULL, offsetof(StatusInfo, chassis { "Chassis", "s", NULL, offsetof(StatusIn
) }, fo, chassis) },
{ "KernelName", "s", NULL, offsetof(StatusInfo, kernel_ { "Deployment", "s", NULL, offsetof(StatusIn
name) }, fo, deployment) },
{ "KernelRelease", "s", NULL, offsetof(StatusInfo, kern { "Location", "s", NULL, offsetof(StatusIn
el_release) }, fo, location) },
{ "OperatingSystemPrettyName", "s", NULL, offsetof(Stat { "KernelName", "s", NULL, offsetof(StatusIn
usInfo, os_pretty_name) }, fo, kernel_name) },
{ "OperatingSystemCPEName", "s", NULL, offsetof(Stat { "KernelRelease", "s", NULL, offsetof(StatusIn
usInfo, os_cpe_name) }, fo, kernel_release) },
{ "OperatingSystemPrettyName", "s", NULL, offsetof(StatusIn
fo, os_pretty_name) },
{ "OperatingSystemCPEName", "s", NULL, offsetof(StatusIn
fo, os_cpe_name) },
{} {}
}; };
static const struct bus_properties_map manager_map[] = { static const struct bus_properties_map manager_map[] = {
{ "Virtualization", "s", NULL, offsetof(StatusInfo, virtual { "Virtualization", "s", NULL, offsetof(StatusIn
ization) }, fo, virtualization) },
{ "Architecture", "s", NULL, offsetof(StatusInfo, archite { "Architecture", "s", NULL, offsetof(StatusIn
cture) }, fo, architecture) },
{} {}
}; };
int r; int r;
r = bus_map_all_properties(bus, r = bus_map_all_properties(bus,
"org.freedesktop.hostname1", "org.freedesktop.hostname1",
"/org/freedesktop/hostname1", "/org/freedesktop/hostname1",
hostname_map, hostname_map,
&info); &info);
skipping to change at line 197 skipping to change at line 210
&info); &info);
print_status_info(&info); print_status_info(&info);
fail: fail:
free(info.hostname); free(info.hostname);
free(info.static_hostname); free(info.static_hostname);
free(info.pretty_hostname); free(info.pretty_hostname);
free(info.icon_name); free(info.icon_name);
free(info.chassis); free(info.chassis);
free(info.deployment);
free(info.location);
free(info.kernel_name); free(info.kernel_name);
free(info.kernel_release); free(info.kernel_release);
free(info.os_pretty_name); free(info.os_pretty_name);
free(info.os_cpe_name); free(info.os_cpe_name);
free(info.virtualization); free(info.virtualization);
free(info.architecture); free(info.architecture);
return r; return r;
} }
skipping to change at line 312 skipping to change at line 327
return set_simple_string(bus, "SetIconName", args[1]); return set_simple_string(bus, "SetIconName", args[1]);
} }
static int set_chassis(sd_bus *bus, char **args, unsigned n) { static int set_chassis(sd_bus *bus, char **args, unsigned n) {
assert(args); assert(args);
assert(n == 2); assert(n == 2);
return set_simple_string(bus, "SetChassis", args[1]); return set_simple_string(bus, "SetChassis", args[1]);
} }
static int help(void) { static int set_deployment(sd_bus *bus, char **args, unsigned n) {
assert(args);
assert(n == 2);
return set_simple_string(bus, "SetDeployment", args[1]);
}
static int set_location(sd_bus *bus, char **args, unsigned n) {
assert(args);
assert(n == 2);
return set_simple_string(bus, "SetLocation", args[1]);
}
static void help(void) {
printf("%s [OPTIONS...] COMMAND ...\n\n" printf("%s [OPTIONS...] COMMAND ...\n\n"
"Query or change system hostname.\n\n" "Query or change system hostname.\n\n"
" -h --help Show this help\n" " -h --help Show this help\n"
" --version Show package version\n" " --version Show package version\n"
" --no-ask-password Do not prompt for password\n" " --no-ask-password Do not prompt for password\n"
" -H --host=[USER@]HOST Operate on remote host\n" " -H --host=[USER@]HOST Operate on remote host\n"
" -M --machine=CONTAINER Operate on local container\n" " -M --machine=CONTAINER Operate on local container\n"
" --transient Only set transient hostname\n" " --transient Only set transient hostname\n"
" --static Only set static hostname\n" " --static Only set static hostname\n"
" --pretty Only set pretty hostname\n\n" " --pretty Only set pretty hostname\n\n"
"Commands:\n" "Commands:\n"
" status Show current hostname settings\n" " status Show current hostname settings\n"
" set-hostname NAME Set system hostname\n" " set-hostname NAME Set system hostname\n"
" set-icon-name NAME Set icon name for host\n" " set-icon-name NAME Set icon name for host\n"
" set-chassis NAME Set chassis type for host\n", " set-chassis NAME Set chassis type for host\n"
program_invocation_short_name); " set-deployment NAME Set deployment environment for hos
t\n"
return 0; " set-location NAME Set location for host\n"
, program_invocation_short_name);
} }
static int parse_argv(int argc, char *argv[]) { static int parse_argv(int argc, char *argv[]) {
enum { enum {
ARG_VERSION = 0x100, ARG_VERSION = 0x100,
ARG_NO_ASK_PASSWORD, ARG_NO_ASK_PASSWORD,
ARG_TRANSIENT, ARG_TRANSIENT,
ARG_STATIC, ARG_STATIC,
ARG_PRETTY ARG_PRETTY
skipping to change at line 361 skipping to change at line 389
{ "machine", required_argument, NULL, 'M' }, { "machine", required_argument, NULL, 'M' },
{ "no-ask-password", no_argument, NULL, ARG_NO_ASK_PA SSWORD }, { "no-ask-password", no_argument, NULL, ARG_NO_ASK_PA SSWORD },
{} {}
}; };
int c; int c;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0) { while ((c = getopt_long(argc, argv, "hH:M:", options, NULL)) >= 0)
switch (c) { switch (c) {
case 'h': case 'h':
return help(); help();
return 0;
case ARG_VERSION: case ARG_VERSION:
puts(PACKAGE_STRING); puts(PACKAGE_STRING);
puts(SYSTEMD_FEATURES); puts(SYSTEMD_FEATURES);
return 0; return 0;
case 'H': case 'H':
arg_transport = BUS_TRANSPORT_REMOTE; arg_transport = BUS_TRANSPORT_REMOTE;
arg_host = optarg; arg_host = optarg;
break; break;
skipping to change at line 405 skipping to change at line 434
case ARG_NO_ASK_PASSWORD: case ARG_NO_ASK_PASSWORD:
arg_ask_password = false; arg_ask_password = false;
break; break;
case '?': case '?':
return -EINVAL; return -EINVAL;
default: default:
assert_not_reached("Unhandled option"); assert_not_reached("Unhandled option");
} }
}
return 1; return 1;
} }
static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) { static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) {
static const struct { static const struct {
const char* verb; const char* verb;
const enum { const enum {
MORE, MORE,
LESS, LESS,
EQUAL EQUAL
} argc_cmp; } argc_cmp;
const int argc; const int argc;
int (* const dispatch)(sd_bus *bus, char **args, unsigned n ); int (* const dispatch)(sd_bus *bus, char **args, unsigned n );
} verbs[] = { } verbs[] = {
{ "status", LESS, 1, show_status }, { "status", LESS, 1, show_status },
{ "set-hostname", EQUAL, 2, set_hostname }, { "set-hostname", EQUAL, 2, set_hostname },
{ "set-icon-name", EQUAL, 2, set_icon_name }, { "set-icon-name", EQUAL, 2, set_icon_name },
{ "set-chassis", EQUAL, 2, set_chassis }, { "set-chassis", EQUAL, 2, set_chassis },
{ "set-deployment", EQUAL, 2, set_deployment },
{ "set-location", EQUAL, 2, set_location },
}; };
int left; int left;
unsigned i; unsigned i;
assert(argc >= 0); assert(argc >= 0);
assert(argv); assert(argv);
left = argc - optind; left = argc - optind;
skipping to change at line 489 skipping to change at line 519
break; break;
default: default:
assert_not_reached("Unknown comparison operator."); assert_not_reached("Unknown comparison operator.");
} }
return verbs[i].dispatch(bus, argv + optind, left); return verbs[i].dispatch(bus, argv + optind, left);
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
_cleanup_bus_unref_ sd_bus *bus = NULL; _cleanup_bus_close_unref_ sd_bus *bus = NULL;
int r; int r;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
log_parse_environment(); log_parse_environment();
log_open(); log_open();
r = parse_argv(argc, argv); r = parse_argv(argc, argv);
if (r <= 0) if (r <= 0)
goto finish; goto finish;
 End of changes. 13 change blocks. 
39 lines changed or deleted 72 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/