about summary refs log tree commit diff
path: root/nis/nss_nis/nis-pwd.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-29 01:14:07 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-29 01:14:07 +0000
commite0d4e91d2b0e8069fc044899cf04a41db3612ffb (patch)
tree6a3f542af192521f75572d7f2cf239ed68478288 /nis/nss_nis/nis-pwd.c
parent4eaa9bb48b319803544909a085651fc6ff4a9ea1 (diff)
downloadglibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.tar.gz
glibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.tar.xz
glibc-e0d4e91d2b0e8069fc044899cf04a41db3612ffb.zip
* nis/nss_nis/nis-spwd.c (internal_nis_getspent_r): Remove data
	variable.

	* nis/nss-nis.h: Define response_t and intern_t.  Declare _nis_saveit.
	* nis/nss_nis/nis-pwd.c: Remove response_t and intern_t definition.
	(saveit): Renamed to _nis_saveit.  Take parameter which is pointer
	to the intern_t object.  Change all users.
	* nis/nss_nis/nis-grp.c: Remove response_t, intern_t, and saveit
	definition.  Use _nis_saveit instead of saveit.
	* nis/nss_nis/nis-service.c: Likewise.
	* nis/nss_nis/nis-initgroups.c: Likewise.
	(internal_setgrent): Adjust for buffer handling.
	(internal_getgrent_r): Likewise.
	* nis/nss_nis/nis-rpc.c: Likewise.
Diffstat (limited to 'nis/nss_nis/nis-pwd.c')
-rw-r--r--nis/nss_nis/nis-pwd.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/nis/nss_nis/nis-pwd.c b/nis/nss_nis/nis-pwd.c
index a996b042c4..7972118c84 100644
--- a/nis/nss_nis/nis-pwd.c
+++ b/nis/nss_nis/nis-pwd.c
@@ -42,34 +42,21 @@ __libc_lock_define_initialized (static, lock)
 static bool_t new_start = 1;
 static char *oldkey;
 static int oldkeylen;
-
-struct response_t
-{
-  struct response_t *next;
-  size_t size;
-  char mem[0];
-};
-
-typedef struct intern_t
-{
-  struct response_t *start;
-  struct response_t *next;
-  size_t offset;
-} intern_t;
-
 static intern_t intern;
 
 
-static int
-saveit (int instatus, char *inkey, int inkeylen, char *inval,
-        int invallen, char *indata)
+int
+_nis_saveit (int instatus, char *inkey, int inkeylen, char *inval,
+	     int invallen, char *indata)
 {
+  intern_t *intern = (intern_t *) indata;
+
   if (instatus != YP_TRUE)
     return 1;
 
   if (inkey && inkeylen > 0 && inval && invallen > 0)
     {
-      struct response_t *bucket = intern.next;
+      struct response_t *bucket = intern->next;
 
       if (__builtin_expect (bucket == NULL, 0))
 	{
@@ -82,10 +69,10 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 
 	  bucket->next = NULL;
 	  bucket->size = minsize;
-	  intern.start = intern.next = bucket;
-	  intern.offset = 0;
+	  intern->start = intern->next = bucket;
+	  intern->offset = 0;
 	}
-      else if (__builtin_expect (invallen + 1 > bucket->size - intern.offset,
+      else if (__builtin_expect (invallen + 1 > bucket->size - intern->offset,
 				 0))
 	{
 	  /* We need a new (larger) buffer.  */
@@ -97,21 +84,21 @@ saveit (int instatus, char *inkey, int inkeylen, char *inval,
 	    return 1;
 
 	  /* Mark the old bucket as full.  */
-	  bucket->size = intern.offset;
+	  bucket->size = intern->offset;
 
 	  newp->next = NULL;
 	  newp->size = newsize;
-	  bucket = intern.next = bucket->next = newp;
-	  intern.offset = 0;
+	  bucket = intern->next = bucket->next = newp;
+	  intern->offset = 0;
 	}
 
-      char *p = mempcpy (&bucket->mem[intern.offset], inval, invallen);
+      char *p = mempcpy (&bucket->mem[intern->offset], inval, invallen);
       if (__builtin_expect (p[-1] != '\0', 0))
 	{
 	  *p = '\0';
 	  ++invallen;
 	}
-      intern.offset += invallen;
+      intern->offset += invallen;
     }
 
   return 0;
@@ -165,8 +152,8 @@ internal_nis_setpwent (void)
 
   struct ypall_callback ypcb;
 
-  ypcb.foreach = saveit;
-  ypcb.data = NULL;
+  ypcb.foreach = _nis_saveit;
+  ypcb.data = (char *) &intern;
   enum nss_status status = yperr2nss (yp_all (domain, "passwd.byname", &ypcb));