#include "sigint.h"
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
#include "stdb.h"
#endif
Command command;
int resolve;
int no_fail;
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
int no_db_lookup;
#endif
} Config;
if (i->interface == interface &&
i->protocol == protocol &&
strcasecmp(i->name, name) == 0 &&
- avahi_domain_equal(i->type, type) == 0 &&
- avahi_domain_equal(i->domain, domain) == 0)
+ avahi_domain_equal(i->type, type) &&
+ avahi_domain_equal(i->domain, domain))
return i;
static void print_service_line(Config *config, char c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) {
char ifname[IF_NAMESIZE];
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
if (!config->no_db_lookup)
type = stdb_lookup(type);
#endif
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);
+ fflush(stdout);
}
static void service_resolver_callback(
assert(n_resolving > 0);
n_resolving--;
check_terminate(i->config);
+ fflush(stdout);
}
static ServiceInfo *add_service(Config *c, AvahiIfIndex interface, AvahiProtocol protocol, const char *name, const char *type, const char *domain) {
if (config->verbose)
fprintf(stderr, "Waiting for daemon ...\n");
- break;
+ break;
}
}
" -c --cache Terminate after dumping all entries from the cache\n"
" -l --ignore-local Ignore local services\n"
" -r --resolve Resolve services found\n"
- " -f --no-fail Don't fail if the server is not available\n"
-#ifdef HAVE_GDBM
- " -k --no-db-lookup Don't lookup service types\n");
+ " -f --no-fail Don't fail if the daemon is not available\n"
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
+ " -k --no-db-lookup Don't lookup service types\n"
#endif
+ );
}
static int parse_command_line(Config *c, const char *argv0, int argc, char *argv[]) {
{ "ignore-local", no_argument, NULL, 'l' },
{ "resolve", no_argument, NULL, 'r' },
{ "no-fail", no_argument, NULL, 'f' },
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
{ "no-db-lookup", no_argument, NULL, 'k' },
#endif
{ NULL, 0, NULL, 0 }
c->no_fail = 0;
c->domain = c->stype = NULL;
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
c->no_db_lookup = 0;
#endif
opterr = 0;
while ((o = getopt_long(argc, argv, "hVd:avtclrDf"
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
"k"
#endif
, long_options, NULL)) >= 0) {
c->command = COMMAND_BROWSE_DOMAINS;
break;
case 'd':
+ avahi_free(c->domain);
c->domain = avahi_strdup(optarg);
break;
case 'v':
case 'f':
c->no_fail = 1;
break;
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
case 'k':
c->no_db_lookup = 1;
break;
#endif
default:
- fprintf(stderr, "Invalid command line argument: %c\n", o);
+ fprintf(stderr, "Invalid command line argument: %s\n", argv[optind-1]);
return -1;
}
}
avahi_string_list_free(browsed_types);
-#ifdef HAVE_GDBM
+#if defined(HAVE_GDBM) || defined(HAVE_DBM)
stdb_shutdown();
#endif