From 8b80182964bde1fa84333674e454d41e1fa0c8ca Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 8 Dec 2000 22:39:54 +0000 Subject: Update. 2000-12-05 H.J. Lu * nss/Makefile (routines): Add getnssent and getnssent_r. * nss/nsswitch.h (__nss_setent): New internal NSS function. (__nss_endent): Likewise. (__nss_getent_r): Likewise. (__nss_getent): Likewise. * nss/getnssent_r.c: New file. * nss/getnssent.c: New file. * nss/getXXent.c (H_ERRNO_VAR): Updated. (GETFUNC_NAME): Updated to call __nss_getent (). * nss/getXXent_r.c (H_ERRNO_VAR_P): New. (STAYOPEN_TMPVAR): Updated. (STAYOPEN_VAR): Updated. (SETFUNC_NAME): Updated to call __nss_setent (). (ENDFUNC_NAME): Updated to call __nss_endent (). (INTERNAL (REENTRANT_GETNAME)): Updated to call __nss_getent_r (). --- nss/getXXent.c | 40 ++++++---------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-) (limited to 'nss/getXXent.c') diff --git a/nss/getXXent.c b/nss/getXXent.c index d2482157ff..0c8bcb4d4d 100644 --- a/nss/getXXent.c +++ b/nss/getXXent.c @@ -48,10 +48,10 @@ /* Sometimes we need to store error codes in the `h_errno' variable. */ #ifdef NEED_H_ERRNO # define H_ERRNO_PARM , int *h_errnop -# define H_ERRNO_VAR , &h_errno +# define H_ERRNO_VAR &h_errno #else # define H_ERRNO_PARM -# define H_ERRNO_VAR +# define H_ERRNO_VAR NULL #endif /* Prototype of the reentrant version. */ @@ -77,42 +77,14 @@ GETFUNC_NAME (void) /* Get lock. */ __libc_lock_lock (lock); - if (buffer == NULL) - { - buffer_size = BUFLEN; - buffer = malloc (buffer_size); - } + result = (LOOKUP_TYPE *) + __nss_getent ((getent_r_function) INTERNAL (REENTRANT_GETNAME), + (void **) &resbuf, &buffer, BUFLEN, &buffer_size, + H_ERRNO_VAR); - while (buffer != NULL - && INTERNAL (REENTRANT_GETNAME) (&resbuf, buffer, buffer_size, &result - H_ERRNO_VAR) == ERANGE -#ifdef NEED_H_ERRNO - && h_errno == NETDB_INTERNAL -#endif - ) - { - char *new_buf; - buffer_size += BUFLEN; - new_buf = realloc (buffer, buffer_size); - if (new_buf == NULL) - { - /* We are out of memory. Free the current buffer so that the - process gets a chance for a normal termination. */ - save = errno; - free (buffer); - __set_errno (save); - } - buffer = new_buf; - } - - if (buffer == NULL) - result = NULL; - - /* Release lock. Preserve error value. */ save = errno; __libc_lock_unlock (lock); __set_errno (save); - return result; } -- cgit v1.2.3