Renamed "internal.h" to the more sensible "busybox.h".
[oweals/busybox.git] / nslookup.c
index e2d8cea1fd8968ac64b62c51dacddf8f089f68b9..acb3e3bb2718dd58dde41c688dda785d2eb3359a 100644 (file)
@@ -2,7 +2,6 @@
 /*
  * Mini nslookup implementation for busybox
  *
- *
  * Copyright (C) 2000 by Lineo, inc.
  * Written by John Beppu <beppu@lineo.com>
  *
@@ -22,7 +21,7 @@
  *
  */
 
-#include "internal.h"
+#include "busybox.h"
 #include <ctype.h>
 #include <errno.h>
 #include <stdio.h>
  |  + find out how the real nslookup gets the default name server
  */
 
-static const char nslookup_usage[] = "nslookup [HOST]\n\n";
-
-
 /* I have to see how the real nslookup does this.
  * I could dig through /etc/resolv.conf, but is there a
  * better (programatic) way?
  */
 static void server_fprint(FILE * dst)
 {
-       fprintf(dst, "Server:  %s\n", "something");
-       fprintf(dst, "Address:  %s\n\n", "something");
+       fprintf(dst, "Server:     %s\n", "default");
+       fprintf(dst, "Address:    %s\n\n", "default");
 }
 
 /* only works for IPv4 */
@@ -97,9 +93,9 @@ static int addr_list_fprint(char **h_addr_list, FILE * dst)
 {
        int i, j;
        char *addr_string = (h_addr_list[1])
-               ? "Addresses" : "Address";
+               ? "Addresses: " : "Address:   ";
 
-       fprintf(dst, "%s ", addr_string);
+       fprintf(dst, "%s ", addr_string);
        for (i = 0, j = 0; h_addr_list[i]; i++, j++) {
                addr_fprint(h_addr_list[i], dst);
 
@@ -133,10 +129,10 @@ static struct hostent *gethostbyaddr_wrapper(const char *address)
 static struct hostent *hostent_fprint(struct hostent *host, FILE * dst)
 {
        if (host) {
-               fprintf(dst, "Name:    %s\n", host->h_name);
+               fprintf(dst, "Name:       %s\n", host->h_name);
                addr_list_fprint(host->h_addr_list, dst);
        } else {
-               fprintf(dst, "*** %s\n", hstrerror(h_errno));
+               fprintf(dst, "*** Unknown host\n");
        }
        return host;
 }
@@ -160,7 +156,7 @@ int nslookup_main(int argc, char **argv)
 {
        struct hostent *host;
 
-       if (argc < 2) {
+       if (argc < 2 || *argv[1]=='-') {
                usage(nslookup_usage);
        }
 
@@ -171,7 +167,7 @@ int nslookup_main(int argc, char **argv)
                host = gethostbyname(argv[1]);
        }
        hostent_fprint(host, stdout);
-       return 0;
+       return( TRUE);
 }
 
-/* $Id: nslookup.c,v 1.5 2000/02/18 21:34:17 erik Exp $ */
+/* $Id: nslookup.c,v 1.12 2000/09/25 21:45:58 andersen Exp $ */