1 | /* NSS service provider that only provides gethostbyname2_r. |
2 | Copyright The GNU Toolchain Authors. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <nss.h> |
20 | #include <stdlib.h> |
21 | #include <string.h> |
22 | #include "nss/tst-nss-gai-hv2-canonname.h" |
23 | |
24 | /* Catch misnamed and functions. */ |
25 | #pragma GCC diagnostic error "-Wmissing-prototypes" |
26 | NSS_DECLARE_MODULE_FUNCTIONS (test_gai_hv2_canonname) |
27 | |
28 | extern enum nss_status _nss_files_gethostbyname2_r (const char *, int, |
29 | struct hostent *, char *, |
30 | size_t, int *, int *); |
31 | |
32 | enum nss_status |
33 | _nss_test_gai_hv2_canonname_gethostbyname2_r (const char *name, int af, |
34 | struct hostent *result, |
35 | char *buffer, size_t buflen, |
36 | int *errnop, int *herrnop) |
37 | { |
38 | return _nss_files_gethostbyname2_r (name, af, result, buffer, buflen, errnop, |
39 | herrnop); |
40 | } |
41 | |
42 | enum nss_status |
43 | _nss_test_gai_hv2_canonname_getcanonname_r (const char *name, char *buffer, |
44 | size_t buflen, char **result, |
45 | int *errnop, int *h_errnop) |
46 | { |
47 | /* We expect QUERYNAME, which is a small enough string that it shouldn't fail |
48 | the test. */ |
49 | if (memcmp (QUERYNAME, name, sizeof (QUERYNAME)) |
50 | || buflen < sizeof (QUERYNAME)) |
51 | abort (); |
52 | |
53 | strncpy (buffer, name, buflen); |
54 | *result = buffer; |
55 | return NSS_STATUS_SUCCESS; |
56 | } |
57 | |