1 /* $NetBSD: hostent.h,v 1.2 2013/08/27 09:56:12 christos Exp $ */
4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
37 * These are not being advertised because the interfaces are non-standard.
38 * There are versions by linux, aix, qnx, sun, etc. Our versions are used
39 * internally to provide thread safety; they mostly resemble qnx.
41 void sethostent_r(FILE **);
42 struct hostent
*gethostent_r(FILE *, struct hostent
*, char *, size_t, int *);
43 void endhostent_r(FILE **);
45 struct hostent
*gethostbyname_r(const char *, struct hostent
*, char *, size_t,
47 struct hostent
*gethostbyname2_r(const char *, int, struct hostent
*, char *,
49 struct hostent
*gethostbyaddr_r(const void *, socklen_t
, int, struct hostent
*,
50 char *, size_t, int *);
55 * The following are internal API's and are used only for testing.
64 /* /etc/hosts lookup */
65 void _hf_sethostsfile(const char *);
66 int _hf_gethtbyaddr(void *, void *, va_list);
67 int _hf_gethtbyname(void *, void *, va_list);
70 int _dns_gethtbyaddr(void *, void *, va_list);
71 int _dns_gethtbyname(void *, void *, va_list);
75 int _yp_gethtbyaddr(void *, void *, va_list);
76 int _yp_gethtbyname(void *, void *, va_list);
79 #define HENT_ARRAY(dst, anum, ptr, len) \
81 size_t _len = (anum + 1) * sizeof(*dst); \
87 } while (/*CONSTCOND*/0)
89 #define HENT_COPY(dst, src, slen, ptr, len) \
91 if ((size_t)slen > len) \
93 memcpy(ptr, src, (size_t)slen); \
97 } while (/* CONSTCOND */0)
99 #define HENT_SCOPY(dst, src, ptr, len) \
101 size_t _len = strlen(src) + 1; \
102 HENT_COPY(dst, src, _len, ptr, len); \
103 } while (/* CONSTCOND */0)
105 #define MAXALIASES 35