| 1 | .TH GETGRENT 3 |
| 2 | .SH NAME |
| 3 | getgrent, getgrgid, getgrnam, setgrent, endgrent \- get group file entry |
| 4 | .SH SYNOPSIS |
| 5 | .B #include <grp.h> |
| 6 | .PP |
| 7 | .B struct group *getgrent(); |
| 8 | .PP |
| 9 | .B struct group *getgrgid(gid) int gid; |
| 10 | .PP |
| 11 | .B struct group *getgrnam(name) char *name; |
| 12 | .PP |
| 13 | .B int setgrent(); |
| 14 | .PP |
| 15 | .B int endgrent(); |
| 16 | .SH DESCRIPTION |
| 17 | .I Getgrent, |
| 18 | .I getgrgid |
| 19 | and |
| 20 | .I getgrnam |
| 21 | each return pointers |
| 22 | to an object |
| 23 | with the following structure |
| 24 | containing the broken-out |
| 25 | fields of a line in the group file. |
| 26 | .RS |
| 27 | .PP |
| 28 | .nf |
| 29 | .so /usr/include/grp.h |
| 30 | .fi |
| 31 | .RE |
| 32 | .PP |
| 33 | The members of this structure are: |
| 34 | .TP |
| 35 | gr_name |
| 36 | The name of the group. |
| 37 | .br |
| 38 | .ns |
| 39 | .TP |
| 40 | gr_passwd |
| 41 | The encrypted password of the group. |
| 42 | .br |
| 43 | .ns |
| 44 | .TP |
| 45 | gr_gid |
| 46 | The numerical group-ID. |
| 47 | .br |
| 48 | .ns |
| 49 | .TP |
| 50 | gr_mem |
| 51 | Null-terminated vector |
| 52 | of pointers to the individual |
| 53 | member names. |
| 54 | .PP |
| 55 | .I Getgrent |
| 56 | simply reads the next |
| 57 | line while |
| 58 | .I getgrgid |
| 59 | and |
| 60 | .I getgrnam |
| 61 | search until a matching |
| 62 | .I gid |
| 63 | or |
| 64 | .I name |
| 65 | is found |
| 66 | (or until EOF is encountered). |
| 67 | Each routine picks up |
| 68 | where the others leave off |
| 69 | so successive calls may be used |
| 70 | to search the entire file. |
| 71 | .PP |
| 72 | A call to |
| 73 | .I setgrent |
| 74 | has the effect of rewinding |
| 75 | the group file |
| 76 | to allow |
| 77 | repeated searches. |
| 78 | .I Endgrent |
| 79 | may be called to |
| 80 | close the group file |
| 81 | when processing is complete. |
| 82 | .SH FILES |
| 83 | /etc/group |
| 84 | .SH "SEE ALSO" |
| 85 | getlogin(3), getpwent(3), group(5) |
| 86 | .SH DIAGNOSTICS |
| 87 | A null pointer |
| 88 | (0) is returned on EOF or error. |
| 89 | .SH BUGS |
| 90 | All information |
| 91 | is contained in a static area |
| 92 | so it must be copied if it is |
| 93 | to be saved. |