summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorSeraphime Kirkovski <kirkseraph@gmail.com>2016-08-31 21:06:57 +0300
committerSven Eden <yamakuzure@gmx.net>2017-07-05 08:50:53 +0200
commit17aeba0786394b9c1b29d56061ee8ed6fbf830eb (patch)
tree1631687c4d76edcebc5685109b367f0041ee01b4 /src/basic
parentf8b903a5947589b91ccfbc5a87ee3f8c5726c354 (diff)
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.
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/string-util.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/string-util.h b/src/basic/string-util.h
index b75aba63c..d029d538b 100644
--- a/src/basic/string-util.h
+++ b/src/basic/string-util.h
@@ -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;