machinectl: split OS field in two; print ip addresses (#4058)

This splits the OS field in two : one for the distribution name
and one for the the version id.
Dashes are written for missing fields.
This also prints ip addresses of known machines. The `--max-addresses`
option specifies how much ip addresses we want to see. The default is 1.
When more than one address is written for a machine, a `,` follows it.
If there are more ips than `--max-addresses`, `...` follows the last
address.
This commit is contained in:
Seraphime Kirkovski
2016-08-31 21:06:57 +03:00
committed by Lennart Poettering
parent c7440e7401
commit 07b0b339d6
4 changed files with 141 additions and 31 deletions

View File

@@ -70,6 +70,10 @@ static inline const char *empty_to_null(const char *p) {
return isempty(p) ? NULL : p;
}
static inline const char *strdash_if_empty(const char *str) {
return isempty(str) ? "-" : str;
}
static inline char *startswith(const char *s, const char *prefix) {
size_t l;