summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.deps.mk4
-rw-r--r--.deps/all.c1
-rw-r--r--.deps/libc.POSIX_11
-rw-r--r--src/grp/__grp.c18
-rw-r--r--src/grp/_grp.h32
5 files changed, 56 insertions, 0 deletions
diff --git a/.deps.mk b/.deps.mk
index e8cbf622..faecadc3 100644
--- a/.deps.mk
+++ b/.deps.mk
@@ -1349,6 +1349,10 @@ libc.a(nl_langinfo.o): $(OBJDIR)/nl_langinfo.o
$(OBJDIR)/nl_langinfo.o: ./src/langinfo/nl_langinfo.c
$(CC) $(BASE_CFLAGS) $(CFLAGS) -c ./src/langinfo/nl_langinfo.c -o $@
echo [CC] $@
+libc.a(__grp.o): $(OBJDIR)/__grp.o
+$(OBJDIR)/__grp.o: ./src/grp/__grp.c
+ $(CC) $(BASE_CFLAGS) $(CFLAGS) -c ./src/grp/__grp.c -o $@
+ echo [CC] $@
libc.a(getgrnam.o): $(OBJDIR)/getgrnam.o
$(OBJDIR)/getgrnam.o: ./src/grp/getgrnam.c
$(CC) $(BASE_CFLAGS) $(CFLAGS) -c ./src/grp/getgrnam.c -o $@
diff --git a/.deps/all.c b/.deps/all.c
index bc3c2820..aa025ba6 100644
--- a/.deps/all.c
+++ b/.deps/all.c
@@ -1027,6 +1027,7 @@
./src/langinfo/ERA.c
./src/langinfo/MON_9.c
./src/langinfo/T_FMT.c
+./src/grp/__grp.c
./src/grp/getgrnam.c
./src/grp/getgrgid.c
./src/grp/endgrent.c
diff --git a/.deps/libc.POSIX_1 b/.deps/libc.POSIX_1
index 7868d0b8..f1e730c4 100644
--- a/.deps/libc.POSIX_1
+++ b/.deps/libc.POSIX_1
@@ -68,6 +68,7 @@ libc_POSIX_1_OBJS= \
libc.a($(OBJDIR)/dup.o) \
libc.a($(OBJDIR)/getgid.o) \
libc.a($(OBJDIR)/sleep.o) \
+ libc.a($(OBJDIR)/__grp.o) \
libc.a($(OBJDIR)/getgrnam.o) \
libc.a($(OBJDIR)/getgrgid.o) \
libc.a($(OBJDIR)/closedir.o) \
diff --git a/src/grp/__grp.c b/src/grp/__grp.c
new file mode 100644
index 00000000..80c8ab4b
--- /dev/null
+++ b/src/grp/__grp.c
@@ -0,0 +1,18 @@
+#include "_grp.h"
+
+#ifndef _XOPEN_SOURCE
+#undef getgrent
+#define getgrent __getgrent
+#include "getgrent.c"
+#endif
+
+struct __grp __grp =
+{
+ NULL,
+ { 0 },
+ getgrent,
+};
+
+/*
+POSIX(1)
+*/
diff --git a/src/grp/_grp.h b/src/grp/_grp.h
new file mode 100644
index 00000000..e3a15be4
--- /dev/null
+++ b/src/grp/_grp.h
@@ -0,0 +1,32 @@
+#ifndef ___GRP_H__
+#define ___GRP_H__
+
+#include <sys/types.h>
+#include <grp.h>
+#include <stdio.h>
+
+#define MAX_MEMBERS 128
+
+struct __grp {
+ FILE *db;
+ struct group grp;
+ struct group * (*getgrent)(void);
+ char *members[MAX_MEMBERS];
+};
+
+extern struct __grp __grp;
+
+#ifndef _XOPEN_SOURCE
+#define setgrent() (__grp.db == NULL ? (void)0 : (void)rewind(__grp.db))
+
+#define endgrent() do { \
+ if (__grp.db) { \
+ fclose(__grp.db); \
+ __grp.db = NULL; \
+ } \
+} while (0)
+
+#define getgrent __grp.getgrent
+#endif
+
+#endif