diff options
Diffstat (limited to 'src/pwd')
| -rw-r--r-- | src/pwd/__pwd.c | 18 | ||||
| -rw-r--r-- | src/pwd/_pwd.h | 29 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/pwd/__pwd.c b/src/pwd/__pwd.c new file mode 100644 index 00000000..c6fb7787 --- /dev/null +++ b/src/pwd/__pwd.c @@ -0,0 +1,18 @@ +#include "_pwd.h" + +#ifndef _XOPEN_SOURCE +#undef getpwent +#define getpwent __getpwent +#include "getpwent.c" +#endif + +struct __pwd __pwd = +{ + NULL, + { 0 }, + getpwent, +}; + +/* +POSIX(1) +*/ 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 |
