X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-utils%2Favahi-browse.c;h=4101895ee208df33b3a7de3b4472a69dfd521d84;hb=7a5b2f69af7d36d6cd4153142f125fa011784e03;hp=e9af2d0e2c533be2f23b076e2399ec7cb052fe68;hpb=b961e134cfaf3077dae0d83efa0fffeacf134fa7;p=catta diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c index e9af2d0..4101895 100644 --- a/avahi-utils/avahi-browse.c +++ b/avahi-utils/avahi-browse.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** This file is part of avahi. @@ -32,6 +30,7 @@ #include #include #include +#include #include #include @@ -140,6 +139,18 @@ static ServiceInfo *find_service(AvahiIfIndex interface, AvahiProtocol protocol, return NULL; } +static char *make_printable(const char *from, char *to) { + const char *f; + char *t; + + for (f = from, t = to; *f; f++, t++) + *t = isprint(*f) ? *f : '_'; + + *t = 0; + + return to; +} + static void print_service_line(Config *config, char c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain, int nl) { char ifname[IF_NAMESIZE]; @@ -158,12 +169,17 @@ static void print_service_line(Config *config, char c, AvahiIfIndex interface, 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 - printf("%c %4s %4s %-*s %-20s %s\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, name, type, domain); + n_columns-35, label, type, domain); + } + fflush(stdout); } @@ -527,10 +543,15 @@ static int start(Config *config) { fprintf(stderr, _("Server version: %s; Host name: %s\n"), version, hn); - if (config->command == COMMAND_BROWSE_DOMAINS) + if (config->command == COMMAND_BROWSE_DOMAINS) { + /* Translators: This is a column heading with abbreviations for + * Event (+/-), Network Interface, Protocol (IPv4/v6), Domain */ fprintf(stderr, _("E Ifce Prot Domain\n")); - else + } else { + /* Translators: This is a column heading with abbreviations for + * Event (+/-), Network Interface, Protocol (IPv4/v6), Domain */ fprintf(stderr, _("E Ifce Prot %-*s %-20s Domain\n"), n_columns-35, _("Name"), _("Type")); + } } if (config->command == COMMAND_BROWSE_SERVICES)