Initial revision
[become] / src / userdb.h
1 /* -*-c-*-
2 *
3 * $Id*
4 *
5 * User database management
6 *
7 * (c) 1997 EBI
8 */
9
10 /*----- Licencing 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
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 */
28
29 /*----- Revision history --------------------------------------------------*
30 *
31 * $Log: userdb.h,v $
32 * Revision 1.1 1997/07/21 13:47:42 mdw
33 * Initial revision
34 *
35 */
36
37 #ifndef USERDB_H
38 #define USERDB_H
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*----- Required headers --------------------------------------------------*/
45
46 #include <grp.h>
47 #include <pwd.h>
48
49 #ifndef SYM_H
50 # include "sym.h"
51 #endif
52
53 /*----- Type definitions --------------------------------------------------*/
54
55 /* --- Iterator objects --- */
56
57 typedef sym_iter userdb_iter;
58
59 /*----- User and group block manipulation ---------------------------------*/
60
61 /* --- @userdb_copyUser@ --- *
62 *
63 * Arguments: @struct passwd *pw@ = pointer to block to copy
64 *
65 * Returns: Pointer to the copy.
66 *
67 * Use: Copies a user block. The copy is `deep' so all the strings
68 * are copied too. Free the copy with @userdb_freeUser@ when
69 * you don't want it any more.
70 */
71
72 extern struct passwd *userdb_copyUser(struct passwd */*pw*/);
73
74 /* --- @userdb_freeUser@ --- *
75 *
76 * Arguments: @void *rec@ = pointer to a user record
77 *
78 * Returns: ---
79 *
80 * Use: Frees a user record.
81 */
82
83 extern void userdb_freeUser(void */*rec*/);
84
85 /* --- @userdb_copyGroup@ --- *
86 *
87 * Arguments: @struct group *gr@ = pointer to group block
88 *
89 * Returns: Pointer to copied block
90 *
91 * Use: Copies a group block. The copy is `deep' so all the strings
92 * are copied too. Free the copy with @userdb_freeGroup@ when
93 * you don't want it any more.
94 */
95
96 extern struct group *userdb_copyGroup(struct group */*gr*/);
97
98 /* --- @userdb_freeGroup@ --- *
99 *
100 * Arguments: @void *rec@ = pointer to a group record
101 *
102 * Returns: ---
103 *
104 * Use: Frees a group record.
105 */
106
107 extern void userdb_freeGroup(void */*rec*/);
108
109 /*----- Internal user database mapping ------------------------------------*/
110
111 /* --- @userdb_local@ --- *
112 *
113 * Arguments: ---
114 *
115 * Returns: ---
116 *
117 * Use: Reads the local list of users into the maps.
118 */
119
120 extern void userdb_local(void);
121
122 /* --- @userdb_yp@ --- *
123 *
124 * Arguments: ---
125 *
126 * Returns: ---
127 *
128 * Use: Fetches the YP database of users.
129 */
130
131 extern void userdb_yp(void);
132
133 /* --- @userdb_userByName@, @userdb_userById@ --- *
134 *
135 * Arguments: @const char *name@ = pointer to user's name
136 * @uid_t id@ = user id to find
137 *
138 * Returns: Pointer to user block, or zero if not found.
139 *
140 * Use: Looks up a user by name or id.
141 */
142
143 extern struct passwd *userdb_userByName(const char */*name*/);
144 extern struct passwd *userdb_userById(uid_t /*id*/);
145
146 /* --- @userdb_iterateUsers@, @userdb_iterateUsers_r@ --- *
147 *
148 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
149 *
150 * Returns: ---
151 *
152 * Use: Initialises an iteration for the user database.
153 */
154
155 extern void userdb_iterateUsers(void);
156 extern void userdb_iterateUsers_r(userdb_iter */*i*/);
157
158 /* --- @userdb_nextUser@, @userdb_nextUser_r@ --- *
159 *
160 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
161 *
162 * Returns: Pointer to the next user block, or null.
163 *
164 * Use: Returns another user block.
165 */
166
167 extern struct passwd *userdb_nextUser(void);
168 extern struct passwd *userdb_nextUser_r(userdb_iter */*i*/);
169
170 /* --- @userdb_groupByName@, @userdb_groupById@ --- *
171 *
172 * Arguments: @const char *name@ = pointer to group's name
173 * @gid_t id@ = group id to find
174 *
175 * Returns: Pointer to group block, or zero if not found.
176 *
177 * Use: Looks up a group by name or id.
178 */
179
180 extern struct group *userdb_groupByName(const char */*name*/);
181 extern struct group *userdb_groupById(gid_t /*id*/);
182
183 /* --- @userdb_iterateGroups@, @userdb_iterateGroups_r@ --- *
184 *
185 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator object
186 *
187 * Returns: ---
188 *
189 * Use: Initialises an iteration for the group database.
190 */
191
192 extern void userdb_iterateGroups(void);
193 extern void userdb_iterateGroups_r(userdb_iter */*i*/);
194
195 /* --- @userdb_nextGroup@, @userdb_nextGroup_r@ --- *
196 *
197 * Arguments: @userdb_iter *i@ = pointer to a symbol table iterator oject
198 *
199 * Returns: Pointer to the next group block, or null.
200 *
201 * Use: Returns another group block.
202 */
203
204 extern struct group *userdb_nextGroup(void);
205 extern struct group *userdb_nextGroup_r(userdb_iter */*i*/);
206
207 /* --- @userdb_init@ --- *
208 *
209 * Arguments: ---
210 *
211 * Returns: ---
212 *
213 * Use: Initialises the user database.
214 */
215
216 extern void userdb_init(void);
217
218 /* --- @userdb_reinit@ --- *
219 *
220 * Arguments: ---
221 *
222 * Returns: ---
223 *
224 * Use: Reinitialises the user database.
225 */
226
227 extern void userdb_reinit(void);
228
229 /*----- That's all, folks -------------------------------------------------*/
230
231 #ifdef __cplusplus
232 }
233 #endif
234
235 #endif