]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - inet/getnetgrent_r.c
Update.
[thirdparty/glibc.git] / inet / getnetgrent_r.c
index ffa45193a93d4f18969830d8368f2dd5fc599f0c..83e4c9ef57f98a746933f1d249bb73a4661ac2f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -16,7 +16,8 @@
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
 
-#include <libc-lock.h>
+#include <bits/libc-lock.h>
+#include <errno.h>
 #include <netdb.h>
 #include <stdlib.h>
 #include <string.h>
@@ -91,7 +92,9 @@ free_memory (struct __netgrent *data)
 }
 \f
 static int
-__internal_setnetgrent_reuse (const char *group, struct __netgrent *datap)
+internal_function
+__internal_setnetgrent_reuse (const char *group, struct __netgrent *datap,
+                             int *errnop)
 {
   enum nss_status (*fct) (const char *, struct __netgrent *);
   enum nss_status status = NSS_STATUS_UNAVAIL;
@@ -114,7 +117,8 @@ __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap)
     {
       if (new_elem != NULL)
        free (new_elem);
-      status = NSS_STATUS_UNAVAIL;
+      *errnop = errno;
+      status = NSS_STATUS_TRYAGAIN;
     }
   else
     {
@@ -131,7 +135,7 @@ __internal_setnetgrent (const char *group, struct __netgrent *datap)
   /* Free list of all netgroup names from last run.  */
   free_memory (datap);
 
-  return __internal_setnetgrent_reuse (group, datap);
+  return __internal_setnetgrent_reuse (group, datap, __errno_location ());
 }
 
 int
@@ -159,7 +163,7 @@ __internal_endnetgrent (struct __netgrent *datap)
   /* Remember which was the last used service.  */
   old_nip = nip;
 
-  /* Cycle through all the services and run their setnetgrent functions.  */
+  /* Cycle through all the services and run their endnetgrent functions.  */
   no_more = setup ((void **) &fct, "endnetgrent", 1);
   while (! no_more)
     {
@@ -187,9 +191,9 @@ endnetgrent (void)
 
 
 int
-__internal_getnetgrent (char **hostp, char **userp, char **domainp,
-                       struct __netgrent *datap,
-                       char *buffer, size_t buflen)
+__internal_getnetgrent_r (char **hostp, char **userp, char **domainp,
+                         struct __netgrent *datap,
+                         char *buffer, size_t buflen, int *errnop)
 {
   enum nss_status (*fct) (struct __netgrent *, char *, size_t);
   int no_more;
@@ -218,7 +222,7 @@ __internal_getnetgrent (char **hostp, char **userp, char **domainp,
              datap->known_groups = tmp;
 
              found = __internal_setnetgrent_reuse (datap->known_groups->name,
-                                                   datap);
+                                                   datap, errnop);
            }
 
          if (found)
@@ -278,8 +282,8 @@ __getnetgrent_r (char **hostp, char **userp, char **domainp,
 
   __libc_lock_lock (lock);
 
-  status = __internal_getnetgrent (hostp, userp, domainp, &dataset,
-                                  buffer, buflen);
+  status = __internal_getnetgrent_r (hostp, userp, domainp, &dataset,
+                                    buffer, buflen, __errno_location ());
 
   __libc_lock_unlock (lock);