summaryrefslogtreecommitdiff
path: root/src/pwd/_pwd.h
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-14 16:27:35 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-14 16:27:35 -0400
commit22f4c7005e9ca07a493f84eac2f529ec369649f3 (patch)
tree93f4ece4d9abe128705ad42c7842605b04e0869e /src/pwd/_pwd.h
parenta4a288cb5dedb82def5e2c2193bd6e9f4a399194 (diff)
add __pwd.c for <pwd.h> internal state
Diffstat (limited to 'src/pwd/_pwd.h')
-rw-r--r--src/pwd/_pwd.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/pwd/_pwd.h b/src/pwd/_pwd.h
new file mode 100644
index 00000000..b5d666bf
--- /dev/null
+++ b/src/pwd/_pwd.h
@@ -0,0 +1,29 @@
+#ifndef ___PWD_H__
+#define ___PWD_H__
+
+#include <sys/types.h>
+#include <pwd.h>
+#include <stdio.h>
+
+struct __pwd {
+ FILE *db;
+ struct passwd pwd;
+ struct passwd * (*getpwent)(void);
+};
+
+extern struct __pwd __pwd;
+
+#ifndef _XOPEN_SOURCE
+#define setpwent() (__pwd.db == NULL ? (void)0 : (void)rewind(__pwd.db))
+
+#define endpwent() do { \
+ if (__pwd.db) { \
+ fclose(__pwd.db); \
+ __pwd.db = NULL; \
+ } \
+} while (0)
+
+#define getpwent __pwd.getpwent
+#endif
+
+#endif