-
- printf("%c %4s %4s %-*s %-20s %s\n",
- c,
- interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : "n/a",
- protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : "n/a",
- n_columns-35, name, type, domain);
+
+ if (config->parsable) {
+ char sn[AVAHI_DOMAIN_NAME_MAX], *e = sn;
+ size_t l = sizeof(sn);
+
+ printf("%c;%s;%s;%s;%s;%s%s",
+ c,
+ interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : _("n/a"),
+ protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : _("n/a"),
+ avahi_escape_label(name, strlen(name), &e, &l), type, domain, nl ? "\n" : "");
+
+ } else {
+ char label[AVAHI_LABEL_MAX];
+ make_printable(name, label);
+
+ printf("%c %6s %4s %-*s %-20s %s\n",
+ c,
+ interface != AVAHI_IF_UNSPEC ? if_indextoname(interface, ifname) : _("n/a"),
+ protocol != AVAHI_PROTO_UNSPEC ? avahi_proto_to_string(protocol) : _("n/a"),
+ n_columns-35, label, type, domain);
+ }
+
+ fflush(stdout);