2 * getgrent - get entry form group file
4 * Author: Patrick van Kleef
6 /* $Id: getgrent.c,v 1.6 1994/06/24 11:45:12 ceriel Exp $ */
14 int open(const char *path, int flags);
17 typedef int off_t; /* see lseek(2) */
22 off_t _lseek(int d, off_t offset, int whence);
23 int _read(int d, char *buf, int nbytes);
27 static char _gr_file[] = "/etc/group";
28 static char _grbuf[256];
29 static char _buffer[RBUFSIZE];
34 static struct group grp;
42 _gfd = open(_gr_file, O_RDONLY);
62 if (_gfd < 0 && setgrent() < 0)
68 if ((_bufcnt = _read(_gfd, _buffer, RBUFSIZE)) <= 0)
74 } while (*_pnt != '\n');
85 while (*_buf && *_buf != ':')
100 grp.gr_gid = atoi(_buf);
106 getgrnam(const char *name)
111 while ((g = getgrent()) != 0)
112 if (!strcmp(g -> gr_name, name))
127 while ((g = getgrent()) != 0)
128 if (g -> gr_gid == gid)