X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-utils%2Favahi-browse.c;h=896e80b9782082571be24a81927ee21125da4c5f;hb=1bf2645c8a15effb3709122b9dd5c478c41c8514;hp=248b6518b28b5af36420f2177791f858beaa2a7b;hpb=b7d566fc3ec60c0fbbca22af273bc67fdc1372fa;p=catta diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c index 248b651..896e80b 100644 --- a/avahi-utils/avahi-browse.c +++ b/avahi-utils/avahi-browse.c @@ -53,6 +53,9 @@ typedef enum { COMMAND_BROWSE_SERVICES, COMMAND_BROWSE_ALL_SERVICES, COMMAND_BROWSE_DOMAINS +#if defined(HAVE_GDBM) || defined(HAVE_DBM) + , COMMAND_DUMP_STDB +#endif } Command; typedef struct Config { @@ -581,7 +584,14 @@ static void help(FILE *f, const char *argv0) { fprintf(f, "%s [options] \n" "%s [options] -a\n" - "%s [options] -D\n\n", + "%s [options] -D\n" +#if defined(HAVE_GDBM) || defined(HAVE_DBM) + "%s [options] -b\n" +#endif + "\n", +#if defined(HAVE_GDBM) || defined(HAVE_DBM) + argv0, +#endif argv0, argv0, argv0); fprintf(f, @@ -598,6 +608,7 @@ static void help(FILE *f, const char *argv0) { " -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" + " -b --dump-db Dump service type database\n" #endif ); } @@ -619,6 +630,7 @@ static int parse_command_line(Config *c, const char *argv0, int argc, char *argv { "no-fail", no_argument, NULL, 'f' }, #if defined(HAVE_GDBM) || defined(HAVE_DBM) { "no-db-lookup", no_argument, NULL, 'k' }, + { "dump-db", no_argument, NULL, 'b' }, #endif { NULL, 0, NULL, 0 } }; @@ -638,10 +650,9 @@ static int parse_command_line(Config *c, const char *argv0, int argc, char *argv c->no_db_lookup = 0; #endif - opterr = 0; while ((o = getopt_long(argc, argv, "hVd:avtclrDf" #if defined(HAVE_GDBM) || defined(HAVE_DBM) - "k" + "kb" #endif , long_options, NULL)) >= 0) { @@ -684,9 +695,11 @@ static int parse_command_line(Config *c, const char *argv0, int argc, char *argv case 'k': c->no_db_lookup = 1; break; + case 'b': + c->command = COMMAND_DUMP_STDB; + break; #endif default: - fprintf(stderr, "Invalid command line argument: %c\n", o); return -1; } } @@ -762,6 +775,23 @@ int main(int argc, char *argv[]) { avahi_simple_poll_loop(simple_poll); ret = 0; break; + +#if defined(HAVE_GDBM) || defined(HAVE_DBM) + case COMMAND_DUMP_STDB: { + char *t; + stdb_setent(); + + while ((t = stdb_getent())) { + if (config.no_db_lookup) + printf("%s\n", t); + else + printf("%s\n", stdb_lookup(t)); + } + + ret = 0; + break; + } +#endif }