]> git.meshlink.io Git - catta/commitdiff
If avahi-resolve is called without command, let it fail
authorLennart Poettering <lennart@poettering.net>
Tue, 15 Nov 2005 01:04:00 +0000 (01:04 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 15 Nov 2005 01:04:00 +0000 (01:04 +0000)
git-svn-id: file:///home/lennart/svn/public/avahi/trunk@972 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-utils/avahi-resolve.c

index f63442906087562889a55ced08ed2e00f955704b..d11e9e3df71d6e1908c9b7cbc8211edcb3586f08 100644 (file)
@@ -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)