linux: Add FSCONFIG_CMD_CREATE_EXCL from Linux 6.6 to sys/mount.h
[glibc.git] / nss / nss_test_gai_hv2_canonname.c
blob4439c83c9f40cf435a32c5576ccff07ef4f98baf
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.
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.
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.
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/>. */
19 #include <nss.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include "nss/tst-nss-gai-hv2-canonname.h"
24 /* Catch misnamed and functions. */
25 #pragma GCC diagnostic error "-Wmissing-prototypes"
26 NSS_DECLARE_MODULE_FUNCTIONS (test_gai_hv2_canonname)
28 extern enum nss_status _nss_files_gethostbyname2_r (const char *, int,
29 struct hostent *, char *,
30 size_t, int *, int *);
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)
38 return _nss_files_gethostbyname2_r (name, af, result, buffer, buflen, errnop,
39 herrnop);
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)
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 ();
53 strncpy (buffer, name, buflen);
54 *result = buffer;
55 return NSS_STATUS_SUCCESS;