diff options
Diffstat (limited to 'nss/digits_dots.c')
-rw-r--r-- | nss/digits_dots.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/nss/digits_dots.c b/nss/digits_dots.c index 57f0e4db67..39bff38865 100644 --- a/nss/digits_dots.c +++ b/nss/digits_dots.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2016 Free Software Foundation, Inc. +/* Copyright (C) 1997-2018 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by H.J. Lu <hjl@gnu.ai.mit.edu>, 1997. @@ -22,7 +22,8 @@ #include <stdlib.h> #include <ctype.h> #include <wctype.h> -#include <resolv.h> +#include <resolv/resolv-internal.h> +#include <resolv/resolv_context.h> #include <netdb.h> #include <arpa/inet.h> #include "nsswitch.h" @@ -38,11 +39,10 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf, size_t buflen, struct hostent **result, enum nss_status *status, int af, int *h_errnop) { - int save; - /* We have to test for the use of IPv6 which can only be done by examining `_res'. */ - if (__res_maybe_init (&_res, 0) == -1) + struct resolv_context *ctx = __resolv_context_get (); + if (ctx == NULL) { if (h_errnop) *h_errnop = NETDB_INTERNAL; @@ -52,6 +52,21 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf, *result = NULL; return -1; } + int ret = __nss_hostname_digits_dots_context + (ctx, name, resbuf, buffer, buffer_size, buflen, + result, status, af, h_errnop); + __resolv_context_put (ctx); + return ret; +} + +int +__nss_hostname_digits_dots_context (struct resolv_context *ctx, + const char *name, struct hostent *resbuf, + char **buffer, size_t *buffer_size, + size_t buflen, struct hostent **result, + enum nss_status *status, int af, int *h_errnop) +{ + int save; /* * disallow names consisting only of digits/dots, unless @@ -80,7 +95,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf, break; default: - af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET; + af = res_use_inet6 () ? AF_INET6 : AF_INET; addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ; break; } @@ -167,7 +182,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf, (*h_addr_ptrs)[0] = (char *) host_addr; (*h_addr_ptrs)[1] = NULL; resbuf->h_addr_list = *h_addr_ptrs; - if (af == AF_INET && (_res.options & RES_USE_INET6)) + if (af == AF_INET && res_use_inet6 ()) { /* We need to change the IP v4 address into the IP v6 address. */ @@ -211,7 +226,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf, switch (af) { default: - af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET; + af = res_use_inet6 () ? AF_INET6 : AF_INET; if (af == AF_INET6) { addr_size = IN6ADDRSZ; |