-/* Copyright (C) 1991 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995 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
/* Search for an entry with a matching group ID. */
struct group *
-DEFUN(getgrgid, (gid), register gid_t gid)
+DEFUN(getgrgid, (gid), gid_t gid)
{
- static PTR info = NULL;
- register FILE *stream;
- register struct group *g;
-
- if (info == NULL)
+ int match (struct group *p)
{
- info = __grpalloc();
- if (info == NULL)
- return NULL;
+ return p->gr_gid == gid;
}
+ static void *info;
- stream = __grpopen();
- if (stream == NULL)
- return NULL;
-
- while ((g = __grpread(stream, info)) != NULL)
- if (g->gr_gid == (gid_t) gid)
- break;
-
- (void) fclose(stream);
- return g;
+ return __grpscan (&info, &match);
}