diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/grp/__grp.c | 18 | ||||
| -rw-r--r-- | src/grp/_grp.h | 32 |
2 files changed, 50 insertions, 0 deletions
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 |
