summaryrefslogtreecommitdiff
path: root/usr/src/lib/libresolv2/common/irs/gethostent_r.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libresolv2/common/irs/gethostent_r.c')
-rw-r--r--usr/src/lib/libresolv2/common/irs/gethostent_r.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/usr/src/lib/libresolv2/common/irs/gethostent_r.c b/usr/src/lib/libresolv2/common/irs/gethostent_r.c
index f6f77b7735..fdb7ee225c 100644
--- a/usr/src/lib/libresolv2/common/irs/gethostent_r.c
+++ b/usr/src/lib/libresolv2/common/irs/gethostent_r.c
@@ -1,29 +1,22 @@
/*
- * Copyright 2001-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
+ * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-1999 by Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: gethostent_r.c,v 8.7 2001/11/01 08:02:09 marka Exp $";
+static const char rcsid[] = "$Id: gethostent_r.c,v 1.9 2005/09/03 12:41:37 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <port_before.h>
@@ -51,10 +44,12 @@ gethostbyname_r(const char *name, struct hostent *hptr, HOST_R_ARGS) {
int n = 0;
#endif
+#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
+#endif
#ifdef HOST_R_SETANSWER
- if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0)
+ if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
@@ -76,10 +71,12 @@ gethostbyaddr_r(const char *addr, int len, int type,
int n = 0;
#endif
+#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
+#endif
#ifdef HOST_R_SETANSWER
- if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0)
+ if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
@@ -93,7 +90,7 @@ gethostbyaddr_r(const char *addr, int len, int type,
#endif
}
-/*
+/*%
* These assume a single context is in operation per thread.
* If this is not the case we will need to call irs directly
* rather than through the base functions.
@@ -106,10 +103,12 @@ gethostent_r(struct hostent *hptr, HOST_R_ARGS) {
int n = 0;
#endif
+#ifdef HOST_R_ERRNO
HOST_R_ERRNO;
+#endif
#ifdef HOST_R_SETANSWER
- if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) == 0)
+ if (he == NULL || (n = copy_hostent(he, hptr, HOST_R_COPY)) != 0)
*answerp = NULL;
else
*answerp = hptr;
@@ -130,6 +129,9 @@ sethostent_r(int stay_open, HOST_R_ENT_ARGS)
sethostent_r(int stay_open)
#endif
{
+#ifdef HOST_R_ENT_ARGS
+ UNUSED(hdptr);
+#endif
sethostent(stay_open);
#ifdef HOST_R_SET_RESULT
return (HOST_R_SET_RESULT);
@@ -143,6 +145,9 @@ endhostent_r(HOST_R_ENT_ARGS)
endhostent_r(void)
#endif
{
+#ifdef HOST_R_ENT_ARGS
+ UNUSED(hdptr);
+#endif
endhostent();
HOST_R_END_RESULT(HOST_R_OK);
}
@@ -158,7 +163,7 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
int nptr, len;
/* Find out the amount of space required to store the answer. */
- nptr = 2; /* NULL ptrs */
+ nptr = 2; /*%< NULL ptrs */
len = (char *)ALIGN(buf) - buf;
for (i = 0; he->h_addr_list[i]; i++, nptr++) {
len += he->h_length;
@@ -221,8 +226,8 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
/* copy up to first 35 addresses */
i = 0;
- cp = hdptr->hostaddr;
- eob = hdptr->hostaddr + sizeof(hdptr->hostaddr);
+ cp = hdptr->hostbuf;
+ eob = hdptr->hostbuf + sizeof(hdptr->hostbuf);
hptr->h_addr_list = hdptr->h_addr_ptrs;
while (he->h_addr_list[i] && i < (_MAXADDRS)) {
if (n < (eob - cp)) {
@@ -237,8 +242,6 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
hptr->h_addr_list[i] = NULL;
/* copy official name */
- cp = hdptr->hostbuf;
- eob = hdptr->hostbuf + sizeof(hdptr->hostbuf);
if ((n = strlen(he->h_name) + 1) < (eob - cp)) {
strcpy(cp, he->h_name);
hptr->h_name = cp;
@@ -269,3 +272,4 @@ copy_hostent(struct hostent *he, struct hostent *hptr, HOST_R_COPY_ARGS) {
static int gethostent_r_unknown_system = 0;
#endif /* HOST_R_RETURN */
#endif /* !defined(_REENTRANT) || !defined(DO_PTHREADS) */
+/*! \file */