version 1.10, 2003/06/13 21:52:25 |
version 1.11, 2003/06/15 16:24:44 |
|
|
#include "utils.h" |
#include "utils.h" |
|
|
struct hash_el { |
struct hash_el { |
uid_t uid; |
uid_t uid; |
char name[9]; |
char name[9]; |
}; |
}; |
|
|
static int enter_user(uid_t, char *, int); |
static int enter_user(uid_t, char *, int); |
static int get_user(uid_t); |
static int get_user(uid_t); |
|
|
#define is_empty_hash(x) (hash_table[x].name[0] == 0) |
#define is_empty_hash(x) (hash_table[x].name[0] == 0) |
|
|
/* simple minded hashing function */ |
/* simple minded hashing function */ |
/* |
/* |
* Uid "nobody" is -2 results in hashit(-2) = -2 which is out of bounds for |
* Uid "nobody" is -2 results in hashit(-2) = -2 which is out of bounds for |
* the hash_table. Applied abs() function to fix. 2/16/96 tpugh |
* the hash_table. Applied abs() function to fix. 2/16/96 tpugh |
*/ |
*/ |
#define hashit(i) (abs(i) % Table_size) |
#define hashit(i) (abs(i) % Table_size) |
|
|
/* K&R requires that statically declared tables be initialized to zero. */ |
/* K&R requires that statically declared tables be initialized to zero. */ |
/* We depend on that for hash_table and YOUR compiler had BETTER do it! */ |
/* We depend on that for hash_table and YOUR compiler had BETTER do it! */ |
|
|
* for now we just do it simply and remember just the result. |
* for now we just do it simply and remember just the result. |
*/ |
*/ |
if ((pwd = getpwnam(username)) == NULL) |
if ((pwd = getpwnam(username)) == NULL) |
return (-1); |
return ((uid_t)-1); |
|
|
/* enter the result in the hash table */ |
/* enter the result in the hash table */ |
enter_user(pwd->pw_uid, username, 1); |
enter_user(pwd->pw_uid, username, 1); |