From 15254fdf717acadf731252c949d2e8c2d29846c7 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 15 Nov 2005 01:04:00 +0000 Subject: [PATCH] If avahi-resolve is called without command, let it fail git-svn-id: file:///home/lennart/svn/public/avahi/trunk@972 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-utils/avahi-resolve.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/avahi-utils/avahi-resolve.c b/avahi-utils/avahi-resolve.c index f634429..d11e9e3 100644 --- a/avahi-utils/avahi-resolve.c +++ b/avahi-utils/avahi-resolve.c @@ -48,6 +48,7 @@ #endif typedef enum { + COMMAND_UNSPEC, COMMAND_HELP, COMMAND_VERSION, COMMAND_RESOLVE_HOST_NAME, @@ -168,8 +169,8 @@ static void help(FILE *f, const char *argv0) { " -6 Lookup IPv6 address\n" " -4 Lookup IPv4 address\n" , - argv0, strstr(argv0, "address") ? "-n" : "[-n]", - argv0, strstr(argv0, "address") ? "[-a]" : "-a"); + argv0, strstr(argv0, "address") ? "[-a]" : "-a", + argv0, strstr(argv0, "host-name") ? "[-n]" : "-n"); } static int parse_command_line(Config *c, int argc, char *argv[]) { @@ -186,7 +187,7 @@ static int parse_command_line(Config *c, int argc, char *argv[]) { assert(c); - c->command = strstr(argv[0], "address") ? COMMAND_RESOLVE_ADDRESS : COMMAND_RESOLVE_HOST_NAME; + c->command = strstr(argv[0], "address") ? COMMAND_RESOLVE_ADDRESS : (strstr(argv[0], "host-name") ? COMMAND_RESOLVE_HOST_NAME : COMMAND_UNSPEC); c->proto = AVAHI_PROTO_UNSPEC; c->verbose = 0; @@ -245,6 +246,11 @@ int main(int argc, char *argv[]) { goto fail; switch (config.command) { + case COMMAND_UNSPEC: + ret = 1; + fprintf(stderr, "No command specified.\n"); + break; + case COMMAND_HELP: help(stdout, argv0); ret = 0; @@ -324,7 +330,6 @@ int main(int argc, char *argv[]) { } } - fail: if (client) -- 2.39.5