Commit | Line | Data |
---|---|---|
62ab31a2 KB |
1 | .\" Copyright (c) 1988 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
5 | .\" @(#)getgrent.3 6.3 (Berkeley) %G% | |
6c9d675c | 6 | .\" |
6548329e | 7 | .TH GETGRENT 3 "" |
6c9d675c KM |
8 | .AT 3 |
9 | .SH NAME | |
f39b3af6 | 10 | getgrent, getgrgid, getgrnam, setgrent, endgrent setgrfile \- get group file entry |
6c9d675c KM |
11 | .SH SYNOPSIS |
12 | .nf | |
62ab31a2 | 13 | .B #include <sys/types.h> |
6c9d675c KM |
14 | .B #include <grp.h> |
15 | .PP | |
16 | .B struct group *getgrent() | |
17 | .PP | |
18 | .B struct group *getgrgid(gid) | |
62ab31a2 | 19 | .B gid_t gid; |
6c9d675c KM |
20 | .PP |
21 | .B struct group *getgrnam(name) | |
22 | .B char *name; | |
23 | .PP | |
24 | .B setgrent() | |
25 | .PP | |
62ab31a2 | 26 | .B void endgrent() |
f39b3af6 | 27 | .PP |
62ab31a2 | 28 | .B void setgrfile(name) |
f39b3af6 | 29 | .B char *name; |
6c9d675c KM |
30 | .fi |
31 | .SH DESCRIPTION | |
32 | .I Getgrent, | |
33 | .I getgrgid | |
34 | and | |
35 | .I getgrnam | |
62ab31a2 KB |
36 | each return pointers to an object with the following structure |
37 | containing the broken-out fields of a line in the group file, | |
38 | as described in | |
39 | .IR < grp.h > . | |
6c9d675c KM |
40 | .RS |
41 | .PP | |
42 | .nf | |
62ab31a2 KB |
43 | struct group { |
44 | char *gr_name; | |
45 | char *gr_passwd; | |
46 | gid_t gr_gid; | |
47 | char **gr_mem; | |
48 | }; | |
49 | .ft R | |
50 | .ad | |
6c9d675c KM |
51 | .fi |
52 | .RE | |
53 | .PP | |
62ab31a2 KB |
54 | The fields have meanings described in |
55 | .IR grp (5). | |
6c9d675c | 56 | .PP |
62ab31a2 KB |
57 | .I Setgrfile |
58 | changes the default group file to | |
59 | .IR name , | |
60 | thus allowing usage of alternate group files. | |
61 | .PP | |
62 | .I Setgrent | |
63 | opens the file (closing any previously opened file) or rewinds it | |
64 | if it it already open. | |
65 | .PP | |
66 | .I Endgrent | |
67 | closes any open files. | |
68 | .PP | |
69 | .I Getgrgid | |
6c9d675c KM |
70 | and |
71 | .I getgrnam | |
62ab31a2 | 72 | search the entire file (opening it if necessary) for a matching |
6c9d675c KM |
73 | .I gid |
74 | or | |
62ab31a2 | 75 | .IR name . |
6c9d675c | 76 | .PP |
62ab31a2 KB |
77 | For programs wishing to read the entire database, |
78 | .I getgrent | |
79 | reads the next entry (opening the file if necessary). | |
6c9d675c KM |
80 | .SH FILES |
81 | /etc/group | |
82 | .SH "SEE ALSO" | |
83 | getlogin(3), getpwent(3), group(5) | |
84 | .SH DIAGNOSTICS | |
62ab31a2 KB |
85 | The routines |
86 | .IR getgrent , | |
87 | .IR getgruid , | |
88 | and | |
89 | .IR getgrnam , | |
90 | return a null pointer (0) on EOF or error. | |
91 | .I Setgrent | |
92 | returns 0 on failure, 1 on success. | |
93 | .I Endgrent | |
94 | and | |
95 | .I setgrfile | |
96 | have no return value. | |
6c9d675c | 97 | .SH BUGS |
62ab31a2 KB |
98 | All information is contained in a static area so it must be |
99 | copied if it is to be saved. |