X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;ds=sidebyside;f=avahi-utils%2Favahi-resolve.c;h=16bb1b59c2e4b5918da815d2ac4180d693592f7b;hb=de6fc99ef5a1767fae07fbea9bc384f512639e57;hp=d11e9e3df71d6e1908c9b7cbc8211edcb3586f08;hpb=15254fdf717acadf731252c949d2e8c2d29846c7;p=catta diff --git a/avahi-utils/avahi-resolve.c b/avahi-utils/avahi-resolve.c index d11e9e3..16bb1b5 100644 --- a/avahi-utils/avahi-resolve.c +++ b/avahi-utils/avahi-resolve.c @@ -43,10 +43,6 @@ #include "sigint.h" -#ifdef HAVE_GDBM -#include "stdb.h" -#endif - typedef enum { COMMAND_UNSPEC, COMMAND_HELP, @@ -159,7 +155,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UN static void help(FILE *f, const char *argv0) { fprintf(f, - "%s [options] %s \n" + "%s [options] %s \n" "%s [options] %s
\n\n" " -h --help Show this help\n" " -V --version Show version\n" @@ -167,13 +163,12 @@ static void help(FILE *f, const char *argv0) { " -a --address Resolve address\n" " -v --verbose Enable verbose mode\n" " -6 Lookup IPv6 address\n" - " -4 Lookup IPv4 address\n" - , - argv0, strstr(argv0, "address") ? "[-a]" : "-a", - argv0, strstr(argv0, "host-name") ? "[-n]" : "-n"); + " -4 Lookup IPv4 address\n", + argv0, strstr(argv0, "host-name") ? "[-n]" : "-n", + argv0, strstr(argv0, "address") ? "[-a]" : "-a"); } -static int parse_command_line(Config *c, int argc, char *argv[]) { +static int parse_command_line(Config *c, const char *argv0, int argc, char *argv[]) { int o; static const struct option long_options[] = { @@ -187,11 +182,10 @@ static int parse_command_line(Config *c, int argc, char *argv[]) { assert(c); - c->command = strstr(argv[0], "address") ? COMMAND_RESOLVE_ADDRESS : (strstr(argv[0], "host-name") ? COMMAND_RESOLVE_HOST_NAME : COMMAND_UNSPEC); + c->command = strstr(argv0, "address") ? COMMAND_RESOLVE_ADDRESS : (strstr(argv0, "host-name") ? COMMAND_RESOLVE_HOST_NAME : COMMAND_UNSPEC); c->proto = AVAHI_PROTO_UNSPEC; c->verbose = 0; - opterr = 0; while ((o = getopt_long(argc, argv, "hVnav46", long_options, NULL)) >= 0) { switch(o) { @@ -217,7 +211,6 @@ static int parse_command_line(Config *c, int argc, char *argv[]) { c->proto = AVAHI_PROTO_INET6; break; default: - fprintf(stderr, "Invalid command line argument: %c\n", o); return -1; } } @@ -242,7 +235,7 @@ int main(int argc, char *argv[]) { else argv0 = argv[0]; - if (parse_command_line(&config, argc, argv) < 0) + if (parse_command_line(&config, argv0, argc, argv) < 0) goto fail; switch (config.command) {