diff options
author | Eric Andersen <andersen@codepoet.org> | 2002-06-17 19:00:59 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2002-06-17 19:00:59 +0000 |
commit | 04b5339fc736b776e9a9af30f4b55ade48203b39 (patch) | |
tree | e2a1504506ea2883c8c401f82b8b4b991e749605 /libc/pwd_grp/getgrgid.c | |
parent | d83aa1f777ba3bacaa5ab65a508ff7d11756c95a (diff) |
Shuffle the logic around a bit
Diffstat (limited to 'libc/pwd_grp/getgrgid.c')
-rw-r--r-- | libc/pwd_grp/getgrgid.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/libc/pwd_grp/getgrgid.c b/libc/pwd_grp/getgrgid.c index 1eaed64c0..dc9176d39 100644 --- a/libc/pwd_grp/getgrgid.c +++ b/libc/pwd_grp/getgrgid.c @@ -26,18 +26,27 @@ struct group *getgrgid(const gid_t gid) { - struct group *group; - int grp_fd; + struct group *group; + int grp_fd; - if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) - return NULL; + if ((grp_fd = open(_PATH_GROUP, O_RDONLY)) < 0) + return NULL; - while ((group = __getgrent(grp_fd)) != NULL) - if (group->gr_gid == gid) { - close(grp_fd); - return group; - } + while ((group = __getgrent(grp_fd)) != NULL) + if (group->gr_gid == gid) { + close(grp_fd); + return group; + } + + close(grp_fd); + return NULL; +} + +#if 0 +/* Search for an entry with a matching group ID. */ +int getgrgid_r (gid_t gid, struct group *resultbuf, char *buffer, + size_t buflen, struct group **result) +{ - close(grp_fd); - return NULL; } +#endif |