summaryrefslogtreecommitdiff
path: root/src/grp/_grp.h
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-14 16:56:59 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-14 16:56:59 -0400
commite83323c4635dd40a0b7c4260b6cbbac12005772e (patch)
tree58c70c175b75e05d3a5d30f058048438b25ce951 /src/grp/_grp.h
parent57a91fc9f0eb8a14ce9ffa4d5218dc8e358fb273 (diff)
add internal state for <grp.h>
Diffstat (limited to 'src/grp/_grp.h')
-rw-r--r--src/grp/_grp.h32
1 files changed, 32 insertions, 0 deletions
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