chiark / gitweb /
machinectl: split OS field in two; print ip addresses (#4058)
authorSeraphime Kirkovski <kirkseraph@gmail.com>
Wed, 31 Aug 2016 18:06:57 +0000 (21:06 +0300)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:53 +0000 (08:50 +0200)
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.

src/basic/string-util.h

index b75aba63c29d4b8ef0341899f5732f5b6d63f694..d029d538bd5ea46ab5cbb26cbc8ef9508623db82 100644 (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;