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