projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
setjmp: optimize x86 longjmp epilogues
[musl]
/
src
/
passwd
/
getgrent.c
diff --git
a/src/passwd/getgrent.c
b/src/passwd/getgrent.c
index
429a3e5
..
835b9ab
100644
(file)
--- a/
src/passwd/getgrent.c
+++ b/
src/passwd/getgrent.c
@@
-1,6
+1,8
@@
#include "pwf.h"
static FILE *f;
#include "pwf.h"
static FILE *f;
+static char *line, **mem;
+static struct group gr;
void setgrent()
{
void setgrent()
{
@@
-12,34
+14,26
@@
weak_alias(setgrent, endgrent);
struct group *getgrent()
{
struct group *getgrent()
{
- static char *line, **mem;
- static struct group gr;
+ struct group *res;
size_t size=0, nmem=0;
if (!f) f = fopen("/etc/group", "rbe");
if (!f) return 0;
size_t size=0, nmem=0;
if (!f) f = fopen("/etc/group", "rbe");
if (!f) return 0;
- return __getgrent_a(f, &gr, &line, &size, &mem, &nmem);
+ __getgrent_a(f, &gr, &line, &size, &mem, &nmem, &res);
+ return res;
}
struct group *getgrgid(gid_t gid)
{
}
struct group *getgrgid(gid_t gid)
{
- struct group *gr;
- int errno_saved;
- setgrent();
- while ((gr=getgrent()) && gr->gr_gid != gid);
- errno_saved = errno;
- endgrent();
- errno = errno_saved;
- return gr;
+ struct group *res;
+ size_t size=0, nmem=0;
+ __getgr_a(0, gid, &gr, &line, &size, &mem, &nmem, &res);
+ return res;
}
struct group *getgrnam(const char *name)
{
}
struct group *getgrnam(const char *name)
{
- struct group *gr;
- int errno_saved;
- setgrent();
- while ((gr=getgrent()) && strcmp(gr->gr_name, name));
- errno_saved = errno;
- endgrent();
- errno = errno_saved;
- return gr;
+ struct group *res;
+ size_t size=0, nmem=0;
+ __getgr_a(name, 0, &gr, &line, &size, &mem, &nmem, &res);
+ return res;
}
}