/*
* Mini nslookup implementation for busybox
*
- *
* Copyright (C) 2000 by Lineo, inc.
* Written by John Beppu <beppu@lineo.com>
*
| + find out how the real nslookup gets the default name server
*/
-static const char nslookup_usage[] = "nslookup [HOST]\n\n";
+static const char nslookup_usage[] = "nslookup [HOST]\n"
+#ifndef BB_FEATURE_TRIVIAL_HELP
+ "\nQueries the nameserver for the IP address of the given HOST\n"
+#endif
+;
/* I have to see how the real nslookup does this.
*/
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 */
static int addr_fprint(char *addr, FILE * dst)
{
- uint8_t split[4];
- uint32_t ip;
- uint32_t *x = (uint32_t *) addr;
+ u_int8_t split[4];
+ u_int32_t ip;
+ u_int32_t *x = (u_int32_t *) addr;
ip = ntohl(*x);
split[0] = (ip & 0xff000000) >> 24;
}
/* changes a c-string matching the perl regex \d+\.\d+\.\d+\.\d+
- * into a uint32_t
+ * into a u_int32_t
*/
-static uint32_t str_to_addr(const char *addr)
+static u_int32_t str_to_addr(const char *addr)
{
- uint32_t split[4];
- uint32_t ip;
+ u_int32_t split[4];
+ u_int32_t ip;
sscanf(addr, "%d.%d.%d.%d",
&split[0], &split[1], &split[2], &split[3]);
{
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.4 2000/02/08 19:58:47 erik Exp $ */
+/* $Id: nslookup.c,v 1.10 2000/06/19 17:25:40 andersen Exp $ */