diff options
Diffstat (limited to 'nis/nss_nis/nis-service.c')
-rw-r--r-- | nis/nss_nis/nis-service.c | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/nis/nss_nis/nis-service.c b/nis/nss_nis/nis-service.c index 6affdb5209..c25422f3ca 100644 --- a/nis/nss_nis/nis-service.c +++ b/nis/nss_nis/nis-service.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996-2001, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996. @@ -88,15 +88,8 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval, } static enum nss_status -internal_nis_setservent (intern_t *intern) +internal_nis_endservent (intern_t * intern) { - char *domainname; - struct ypall_callback ypcb; - enum nss_status status; - - if (yp_get_default_domain (&domainname)) - return NSS_STATUS_UNAVAIL; - while (intern->start != NULL) { if (intern->start->val != NULL) @@ -107,21 +100,17 @@ internal_nis_setservent (intern_t *intern) } intern->start = NULL; - ypcb.foreach = saveit; - ypcb.data = (char *) intern; - status = yperr2nss (yp_all (domainname, "services.byname", &ypcb)); - intern->next = intern->start; - - return status; + return NSS_STATUS_SUCCESS; } + enum nss_status -_nss_nis_setservent (int stayopen) +_nss_nis_endservent (void) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_setservent (&intern); + status = internal_nis_endservent (&intern); __libc_lock_unlock (lock); @@ -129,29 +118,32 @@ _nss_nis_setservent (int stayopen) } static enum nss_status -internal_nis_endservent (intern_t * intern) +internal_nis_setservent (intern_t *intern) { - while (intern->start != NULL) - { - if (intern->start->val != NULL) - free (intern->start->val); - intern->next = intern->start; - intern->start = intern->start->next; - free (intern->next); - } - intern->start = NULL; + char *domainname; + struct ypall_callback ypcb; + enum nss_status status; - return NSS_STATUS_SUCCESS; -} + if (yp_get_default_domain (&domainname)) + return NSS_STATUS_UNAVAIL; + (void) internal_nis_endservent (intern); + + ypcb.foreach = saveit; + ypcb.data = (char *) intern; + status = yperr2nss (yp_all (domainname, "services.byname", &ypcb)); + intern->next = intern->start; + + return status; +} enum nss_status -_nss_nis_endservent (void) +_nss_nis_setservent (int stayopen) { enum nss_status status; __libc_lock_lock (lock); - status = internal_nis_endservent (&intern); + status = internal_nis_setservent (&intern); __libc_lock_unlock (lock); |