diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-12-08 22:39:54 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-12-08 22:39:54 +0000 |
commit | 8b80182964bde1fa84333674e454d41e1fa0c8ca (patch) | |
tree | dfdb69a6a515ee5b4152036e710c3ea1fb0f96ec /nss/getXXent.c | |
parent | 55f44129526d6bae0595300c03fcd681f83ededb (diff) | |
download | glibc-8b80182964bde1fa84333674e454d41e1fa0c8ca.tar glibc-8b80182964bde1fa84333674e454d41e1fa0c8ca.tar.gz glibc-8b80182964bde1fa84333674e454d41e1fa0c8ca.tar.bz2 glibc-8b80182964bde1fa84333674e454d41e1fa0c8ca.zip |
Update.
2000-12-05 H.J. Lu <hjl@gnu.org>
* 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 ().
Diffstat (limited to 'nss/getXXent.c')
-rw-r--r-- | nss/getXXent.c | 40 |
1 files changed, 6 insertions, 34 deletions
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; } |