diff options
Diffstat (limited to 'usr/src/lib/libresolv2/common')
-rw-r--r-- | usr/src/lib/libresolv2/common/irs/lcl_ho.c | 52 | ||||
-rw-r--r-- | usr/src/lib/libresolv2/common/isc/logging.c | 6 | ||||
-rw-r--r-- | usr/src/lib/libresolv2/common/resolv/res_init.c | 22 | ||||
-rw-r--r-- | usr/src/lib/libresolv2/common/resolv/res_query.c | 27 |
4 files changed, 17 insertions, 90 deletions
diff --git a/usr/src/lib/libresolv2/common/irs/lcl_ho.c b/usr/src/lib/libresolv2/common/irs/lcl_ho.c index cebf63ef08..469cbb7f41 100644 --- a/usr/src/lib/libresolv2/common/irs/lcl_ho.c +++ b/usr/src/lib/libresolv2/common/irs/lcl_ho.c @@ -1,5 +1,5 @@ /* - * Copyright 1997-2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -87,9 +87,6 @@ static const char rcsid[] = "$Id: lcl_ho.c,v 1.26 2001/05/29 05:49:04 marka Exp #include <isc/memcluster.h> #include "port_after.h" -#ifdef SUNW_AVOIDSTDIO_FDLIMIT -#include "../../../libnsl/include/nsl_stdio_prv.h" -#endif #include "irs_p.h" #include "dns_p.h" @@ -114,11 +111,7 @@ static const char rcsid[] = "$Id: lcl_ho.c,v 1.26 2001/05/29 05:49:04 marka Exp #endif struct pvt { -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - __NSL_FILE * fp; -#else FILE * fp; -#endif struct hostent host; char * h_addr_ptrs[MAXADDRS + 1]; char * host_aliases[MAXALIASES]; @@ -205,11 +198,7 @@ ho_close(struct irs_ho *this) { ho_minimize(this); if (pvt->fp) -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - (void) __nsl_fclose(pvt->fp); -#else (void) fclose(pvt->fp); -#endif if (pvt->res && pvt->free_res) (*pvt->free_res)(pvt->res); memput(pvt, sizeof *pvt); @@ -358,21 +347,13 @@ ho_next(struct irs_ho *this) { bufsiz = sizeof pvt->hostbuf; offset = 0; again: -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if (!(p = __nsl_fgets(bufp + offset, bufsiz - offset, pvt->fp))) { -#else if (!(p = fgets(bufp + offset, bufsiz - offset, pvt->fp))) { -#endif RES_SET_H_ERRNO(pvt->res, HOST_NOT_FOUND); if (dbuf) free(dbuf); return (NULL); } -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if (!strchr(p, '\n') && !__nsl_feof(pvt->fp)) { -#else if (!strchr(p, '\n') && !feof(pvt->fp)) { -#endif #define GROWBUF 1024 /* allocate space for longer line */ if (dbuf == NULL) { @@ -387,19 +368,11 @@ ho_next(struct irs_ho *this) { offset = strlen(dbuf); } else { /* allocation failed; skip this long line */ -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - while ((c = __nsl_getc(pvt->fp)) != EOF) -#else while ((c = getc(pvt->fp)) != EOF) -#endif if (c == '\n') break; if (c != EOF) -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - __nsl_ungetc(c, pvt->fp); -#else ungetc(c, pvt->fp); -#endif } goto again; } @@ -462,32 +435,21 @@ static void ho_rewind(struct irs_ho *this) { struct pvt *pvt = (struct pvt *)this->private; -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if (pvt->fp) { - if (__nsl_fseek(pvt->fp, 0L, SEEK_SET) == 0) - return; - (void)__nsl_fclose(pvt->fp); - } - if (!(pvt->fp = __nsl_fopen(_PATH_HOSTS, "r"))) - return; - if (fcntl(__nsl_fileno(pvt->fp), F_SETFD, 1) < 0) { - (void)__nsl_fclose(pvt->fp); - pvt->fp = NULL; - } -#else if (pvt->fp) { if (fseek(pvt->fp, 0L, SEEK_SET) == 0) return; (void)fclose(pvt->fp); } +#ifdef SUNW_AVOIDSTDIO_FDLIMIT + if (!(pvt->fp = fopen(_PATH_HOSTS, "rF"))) +#else if (!(pvt->fp = fopen(_PATH_HOSTS, "r"))) +#endif return; if (fcntl(fileno(pvt->fp), F_SETFD, 1) < 0) { (void)fclose(pvt->fp); pvt->fp = NULL; } -#endif - } static void @@ -495,11 +457,7 @@ ho_minimize(struct irs_ho *this) { struct pvt *pvt = (struct pvt *)this->private; if (pvt->fp != NULL) { -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - (void)__nsl_fclose(pvt->fp); -#else (void)fclose(pvt->fp); -#endif pvt->fp = NULL; } if (pvt->res) diff --git a/usr/src/lib/libresolv2/common/isc/logging.c b/usr/src/lib/libresolv2/common/isc/logging.c index 48ce0859c9..f279ea525d 100644 --- a/usr/src/lib/libresolv2/common/isc/logging.c +++ b/usr/src/lib/libresolv2/common/isc/logging.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -158,7 +158,11 @@ log_open_stream(log_channel chan) { chan->flags |= LOG_CHANNEL_BROKEN; return (NULL); } +#ifdef SUNW_AVOIDSTDIO_FDLIMIT + stream = fdopen(fd, "aF"); +#else stream = fdopen(fd, "a"); +#endif if (stream == NULL) { syslog(LOG_ERR, "log_open_stream: fdopen() failed"); chan->flags |= LOG_CHANNEL_BROKEN; diff --git a/usr/src/lib/libresolv2/common/resolv/res_init.c b/usr/src/lib/libresolv2/common/resolv/res_init.c index 06b35591b1..e0eac579e4 100644 --- a/usr/src/lib/libresolv2/common/resolv/res_init.c +++ b/usr/src/lib/libresolv2/common/resolv/res_init.c @@ -1,5 +1,5 @@ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -99,9 +99,6 @@ static const char rcsid[] = "$Id: res_init.c,v 8.32 2003/04/03 06:31:10 marka Ex #include <netdb.h> #include "port_after.h" -#ifdef SUNW_AVOIDSTDIO_FDLIMIT -#include "../../../libnsl/include/nsl_stdio_prv.h" -#endif /* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */ #include <resolv.h> @@ -176,11 +173,7 @@ res_ninit(res_state statp) { /* This function has to be reachable by res_data.c but not publically. */ int __res_vinit(res_state statp, int preinit) { -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - register __NSL_FILE *fp; -#else register FILE *fp; -#endif register char *cp, **pp; register int n; char buf[BUFSIZ]; @@ -396,15 +389,13 @@ __res_vinit(res_state statp, int preinit) { nserv = 0; -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if ((fp = __nsl_fopen(_PATH_RESCONF, "r")) != NULL) { - /* read the config file */ - while (__nsl_fgets(buf, sizeof(buf), fp) != NULL) { +#ifdef SUNW_AVOIDSTDIO_FDLIMIT + if ((fp = fopen(_PATH_RESCONF, "rF")) != NULL) { #else if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { +#endif /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { -#endif /* skip comments */ if (*buf == ';' || *buf == '#') continue; @@ -550,12 +541,7 @@ __res_vinit(res_state statp, int preinit) { #ifdef RESOLVSORT statp->nsort = nsort; #endif - -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - (void) __nsl_fclose(fp); -#else (void) fclose(fp); -#endif } /* * Last chance to get a nameserver. This should not normally diff --git a/usr/src/lib/libresolv2/common/resolv/res_query.c b/usr/src/lib/libresolv2/common/resolv/res_query.c index 55746f572f..b592f4e72f 100644 --- a/usr/src/lib/libresolv2/common/resolv/res_query.c +++ b/usr/src/lib/libresolv2/common/resolv/res_query.c @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -94,9 +94,6 @@ static const char rcsid[] = "$Id: res_query.c,v 8.24 2003/01/31 15:25:58 vixie E #include <stdlib.h> #include <string.h> #include "port_after.h" -#ifdef SUNW_AVOIDSTDIO_FDLIMIT -#include "../../../libnsl/include/nsl_stdio_prv.h" -#endif /* Options. Leave them on. */ #define DEBUG @@ -407,30 +404,20 @@ const char * res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { char *file, *cp1, *cp2; char buf[BUFSIZ]; -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - __NSL_FILE *fp; -#else FILE *fp; -#endif if (statp->options & RES_NOALIASES) return (NULL); file = getenv("HOSTALIASES"); -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - if (file == NULL || (fp = __nsl_fopen(file, "r")) == NULL) +#ifdef SUNW_AVOIDSTDIO_FDLIMIT + if (file == NULL || (fp = fopen(file, "rF")) == NULL) #else if (file == NULL || (fp = fopen(file, "r")) == NULL) #endif return (NULL); -#ifndef SUNW_AVOIDSTDIO_FDLIMIT setbuf(fp, NULL); -#endif buf[sizeof(buf) - 1] = '\0'; -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - while (__nsl_fgets(buf, sizeof(buf), fp)) { -#else while (fgets(buf, sizeof(buf), fp)) { -#endif for (cp1 = buf; *cp1 && !isspace((unsigned char)*cp1); ++cp1) ; if (!*cp1) @@ -447,18 +434,10 @@ res_hostalias(const res_state statp, const char *name, char *dst, size_t siz) { *cp2 = '\0'; strncpy(dst, cp1, siz - 1); dst[siz - 1] = '\0'; -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - __nsl_fclose(fp); -#else fclose(fp); -#endif return (dst); } } -#ifdef SUNW_AVOIDSTDIO_FDLIMIT - __nsl_fclose(fp); -#else fclose(fp); -#endif return (NULL); } |