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