chiark / gitweb /
manual/Makefile.am: Install the HTML version of the manual correctly.
[become] / src / userdb.h
1 /* -*-c-*-
2  *
3  * $Id*
4  *
5  * User database management
6  *
7  * (c) 1998 EBI
8  */
9
10 /*----- Licensing notice --------------------------------------------------*
11  *
12  * This file is part of `become'
13  *
14  * `Become' is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * `Become' is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with `become'; if not, write to the Free Software Foundation,
26  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27  */
28
29 #ifndef USERDB_H
30 #define USERDB_H
31
32 #ifdef __cplusplus
33   extern "C" {
34 #endif
35
36 /*----- Required headers --------------------------------------------------*/
37
38 #include <grp.h>
39 #include <pwd.h>
40
41 #include <mLib/sym.h>
42
43 /*----- Type definitions --------------------------------------------------*/
44
45 /* --- Iterator objects --- */
46
47 typedef sym_iter userdb_iter;
48
49 /*----- User and group block manipulation ---------------------------------*/
50
51 /* --- @userdb_copyUser@ --- *
52  *
53  * Arguments:   @struct passwd *pw@ = pointer to block to copy
54  *
55  * Returns:     Pointer to the copy.
56  *
57  * Use:         Copies a user block.  The copy is `deep' so all the strings
58  *              are copied too.  Free the copy with @userdb_freeUser@ when
59  *              you don't want it any more.
60  */
61
62 extern struct passwd *userdb_copyUser(struct passwd */*pw*/);
63
64 /* --- @userdb_freeUser@ --- *
65  *
66  * Arguments:   @void *rec@ = pointer to a user record
67  *
68  * Returns:     ---
69  *
70  * Use:         Frees a user record.
71  */
72
73 extern void userdb_freeUser(void */*rec*/);
74
75 /* --- @userdb_copyGroup@ --- *
76  *
77  * Arguments:   @struct group *gr@ = pointer to group block
78  *
79  * Returns:     Pointer to copied block
80  *
81  * Use:         Copies a group block.  The copy is `deep' so all the strings
82  *              are copied too.  Free the copy with @userdb_freeGroup@ when
83  *              you don't want it any more.
84  */
85
86 extern struct group *userdb_copyGroup(struct group */*gr*/);
87
88 /* --- @userdb_freeGroup@ --- *
89  *
90  * Arguments:   @void *rec@ = pointer to a group record
91  *
92  * Returns:     ---
93  *
94  * Use:         Frees a group record.
95  */
96
97 extern void userdb_freeGroup(void */*rec*/);
98
99 /*----- Internal user database mapping ------------------------------------*/
100
101 /* --- @userdb_local@ --- *
102  *
103  * Arguments:   ---
104  *
105  * Returns:     ---
106  *
107  * Use:         Reads the local list of users into the maps.
108  */
109
110 extern void userdb_local(void);
111
112 /* --- @userdb_yp@ --- *
113  *
114  * Arguments:   ---
115  *
116  * Returns:     ---
117  *
118  * Use:         Fetches the YP database of users.
119  */
120
121 extern void userdb_yp(void);
122
123 /* --- @userdb_userByName@, @userdb_userById@ --- *
124  *
125  * Arguments:   @const char *name@ = pointer to user's name
126  *              @uid_t id@ = user id to find
127  *
128  * Returns:     Pointer to user block, or zero if not found.
129  *
130  * Use:         Looks up a user by name or id.
131  */
132
133 extern struct passwd *userdb_userByName(const char */*name*/);
134 extern struct passwd *userdb_userById(uid_t /*id*/);
135
136 /* --- @userdb_iterateUsers@, @userdb_iterateUsers_r@ --- *
137  *
138  * Arguments:   @userdb_iter *i@ = pointer to a symbol table iterator object
139  *
140  * Returns:     ---
141  *
142  * Use:         Initialises an iteration for the user database.
143  */
144
145 extern void userdb_iterateUsers(void);
146 extern void userdb_iterateUsers_r(userdb_iter */*i*/);
147
148 /* --- @userdb_nextUser@, @userdb_nextUser_r@ --- *
149  *
150  * Arguments:   @userdb_iter *i@ = pointer to a symbol table iterator oject
151  *
152  * Returns:     Pointer to the next user block, or null.
153  *
154  * Use:         Returns another user block.
155  */
156
157 extern struct passwd *userdb_nextUser(void);
158 extern struct passwd *userdb_nextUser_r(userdb_iter */*i*/);
159
160 /* --- @userdb_groupByName@, @userdb_groupById@ --- *
161  *
162  * Arguments:   @const char *name@ = pointer to group's name
163  *              @gid_t id@ = group id to find
164  *
165  * Returns:     Pointer to group block, or zero if not found.
166  *
167  * Use:         Looks up a group by name or id.
168  */
169
170 extern struct group *userdb_groupByName(const char */*name*/);
171 extern struct group *userdb_groupById(gid_t /*id*/);
172
173 /* --- @userdb_iterateGroups@, @userdb_iterateGroups_r@ --- *
174  *
175  * Arguments:   @userdb_iter *i@ = pointer to a symbol table iterator object
176  *
177  * Returns:     ---
178  *
179  * Use:         Initialises an iteration for the group database.
180  */
181
182 extern void userdb_iterateGroups(void);
183 extern void userdb_iterateGroups_r(userdb_iter */*i*/);
184
185 /* --- @userdb_nextGroup@, @userdb_nextGroup_r@ --- *
186  *
187  * Arguments:   @userdb_iter *i@ = pointer to a symbol table iterator oject
188  *
189  * Returns:     Pointer to the next group block, or null.
190  *
191  * Use:         Returns another group block.
192  */
193
194 extern struct group *userdb_nextGroup(void);
195 extern struct group *userdb_nextGroup_r(userdb_iter */*i*/);
196
197 /* --- @userdb_init@ --- *
198  *
199  * Arguments:   ---
200  *
201  * Returns:     ---
202  *
203  * Use:         Initialises the user database.
204  */
205
206 extern void userdb_init(void);
207
208 /* --- @userdb_end@ --- *
209  *
210  * Arguments:   ---
211  *
212  * Returns:     ---
213  *
214  * Use:         Closes down the user database.
215  */
216
217 extern void userdb_end(void);
218
219 /*----- That's all, folks -------------------------------------------------*/
220
221 #ifdef __cplusplus
222   }
223 #endif
224
225 #endif