Lines Matching refs:uidc
50 struct uidc {
54 struct uidc *next; /* for collisions */
64 static struct uidc **uidtoname; /* uid to user name cache */
66 static struct uidc **nametouid; /* user name to uid cache */
134 uidc_insert(struct uidc **tbl, struct uidc *uidc, uint32_t key)
137 uidc->next = tbl[key];
138 tbl[key] = uidc;
154 struct uidc *uidc, *uidc2;
159 uidc = uidtoname[key];
160 while (uidc != NULL) {
161 if (uidc->uid == uid)
163 uidc = uidc->next;
166 if (uidc == NULL) {
168 uidc = xmalloc(sizeof(struct uidc));
169 uidc->uid = uid;
173 uidc->name = xstrdup(pw->pw_name);
174 uidc->valid = 1;
176 uidc2 = xmalloc(sizeof(struct uidc));
178 uidc2->name = uidc->name; /* We reuse the pointer. */
180 key2 = hash(uidc->name) % NAMETOUID_SZ;
184 uidc->name = NULL;
185 uidc->valid = 0;
187 uidc_insert(uidtoname, uidc, key);
192 return (uidc->name);
247 struct uidc *uidc, *uidc2;
252 uidc = nametouid[key];
253 while (uidc != NULL) {
254 if (strcmp(uidc->name, name) == 0)
256 uidc = uidc->next;
259 if (uidc == NULL) {
260 uidc = xmalloc(sizeof(struct uidc));
261 uidc->name = xstrdup(name);
265 uidc->valid = 1;
266 uidc->uid = pw->pw_uid;
268 uidc2 = xmalloc(sizeof(struct uidc));
269 uidc2->name = uidc->name; /* We reuse the pointer. */
270 uidc2->uid = uidc->uid;
276 uidc->valid = 0;
277 uidc->uid = (uid_t)-1; /* Should not be accessed. */
279 uidc_insert(nametouid, uidc, key);
284 if (!uidc->valid)
286 *uid = uidc->uid;
346 uidtoname = xmalloc(UIDTONAME_SZ * sizeof(struct uidc *));
348 nametouid = xmalloc(NAMETOUID_SZ * sizeof(struct uidc *));
350 memset(uidtoname, 0, UIDTONAME_SZ * sizeof(struct uidc *));
352 memset(nametouid, 0, NAMETOUID_SZ * sizeof(struct uidc *));
360 struct uidc *uidc, *uidc2;
365 uidc = uidtoname[i];
366 while (uidc != NULL) {
367 if (uidc->name != NULL) {
368 assert(uidc->valid);
369 free(uidc->name);
371 uidc2 = uidc->next;
372 free(uidc);
373 uidc = uidc2;
378 uidc = nametouid[i];
379 while (uidc != NULL) {
380 assert(uidc->name != NULL);
385 if (!uidc->valid)
386 free(uidc->name);
387 uidc2 = uidc->next;
388 free(uidc);
389 uidc = uidc2;