/*
* Mini nslookup implementation for busybox
*
- *
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
*
*/
-#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 */
{
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);
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;
}
{
struct hostent *host;
- if (argc < 2) {
+ if (argc < 2 || *argv[1]=='-') {
usage(nslookup_usage);
}
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 $ */