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