nslookup: tiny shrink (-5 bytes); add comment about res_init
inet_common: cosmetics, no code changes
This commit is contained in:
parent
c51457ca5b
commit
391ffa19d1
@ -63,9 +63,6 @@ int FAST_FUNC INET_resolve(const char *name, struct sockaddr_in *s_in, int hostf
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
res_init();
|
res_init();
|
||||||
_res.options |= RES_DEBUG;
|
_res.options |= RES_DEBUG;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
bb_error_msg("gethostbyname(%s)", name);
|
bb_error_msg("gethostbyname(%s)", name);
|
||||||
#endif
|
#endif
|
||||||
hp = gethostbyname(name);
|
hp = gethostbyname(name);
|
||||||
|
@ -15,8 +15,11 @@
|
|||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm only implementing non-interactive mode;
|
* I'm only implementing non-interactive mode;
|
||||||
* I totally forgot nslookup even had an interactive mode.
|
* I totally forgot nslookup even had an interactive mode.
|
||||||
|
*
|
||||||
|
* This applet is the only user of res_init(). Without it,
|
||||||
|
* you may avoid pulling in _res global from libc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Examples of 'standard' nslookup output
|
/* Examples of 'standard' nslookup output
|
||||||
@ -51,7 +54,6 @@ static int print_host(const char *hostname, const char *header)
|
|||||||
{
|
{
|
||||||
/* We can't use xhost2sockaddr() - we want to get ALL addresses,
|
/* We can't use xhost2sockaddr() - we want to get ALL addresses,
|
||||||
* not just one */
|
* not just one */
|
||||||
|
|
||||||
struct addrinfo *result = NULL;
|
struct addrinfo *result = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
struct addrinfo hint;
|
struct addrinfo hint;
|
||||||
@ -116,7 +118,7 @@ static void server_print(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* alter the global _res nameserver structure to use
|
/* alter the global _res nameserver structure to use
|
||||||
an explicit dns server instead of what is in /etc/resolv.h */
|
an explicit dns server instead of what is in /etc/resolv.conf */
|
||||||
static void set_default_dns(char *server)
|
static void set_default_dns(char *server)
|
||||||
{
|
{
|
||||||
struct in_addr server_in_addr;
|
struct in_addr server_in_addr;
|
||||||
@ -135,18 +137,17 @@ int nslookup_main(int argc, char **argv)
|
|||||||
* optional DNS server with which to do the lookup.
|
* optional DNS server with which to do the lookup.
|
||||||
* More than 3 arguments is an error to follow the pattern of the
|
* More than 3 arguments is an error to follow the pattern of the
|
||||||
* standard nslookup */
|
* standard nslookup */
|
||||||
|
if (!argv[1] || argv[1][0] == '-' || argc > 3)
|
||||||
if (argc < 2 || *argv[1] == '-' || argc > 3)
|
|
||||||
bb_show_usage();
|
bb_show_usage();
|
||||||
|
|
||||||
/* initialize DNS structure _res used in printing the default
|
/* initialize DNS structure _res used in printing the default
|
||||||
* name server and in the explicit name server option feature. */
|
* name server and in the explicit name server option feature. */
|
||||||
res_init();
|
res_init();
|
||||||
/* rfc2133 says this enables IPv6 lookups */
|
/* rfc2133 says this enables IPv6 lookups */
|
||||||
/* (but it also says "may be enabled in /etc/resolv.conf|) */
|
/* (but it also says "may be enabled in /etc/resolv.conf") */
|
||||||
/*_res.options |= RES_USE_INET6;*/
|
/*_res.options |= RES_USE_INET6;*/
|
||||||
|
|
||||||
if (argc == 3)
|
if (argv[2])
|
||||||
set_default_dns(argv[2]);
|
set_default_dns(argv[2]);
|
||||||
|
|
||||||
server_print();
|
server_print();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user