version 1.1, 1997/08/14 14:00:27 |
version 1.2, 1997/08/22 07:16:31 |
|
|
* This makes the table size independent of the passwd file size. |
* This makes the table size independent of the passwd file size. |
*/ |
*/ |
|
|
|
#include <sys/types.h> |
#include <stdio.h> |
#include <stdio.h> |
|
#include <string.h> |
#include <pwd.h> |
#include <pwd.h> |
|
|
#include "top.local.h" |
#include "top.local.h" |
#include "utils.h" |
#include "utils.h" |
|
|
struct hash_el { |
struct hash_el { |
int uid; |
uid_t uid; |
char name[9]; |
char name[9]; |
}; |
}; |
|
|
|
static int enter_user __P((uid_t, char *, int)); |
|
static int get_user __P((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 */ |
|
|
/* 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! */ |
struct hash_el hash_table[Table_size]; |
struct hash_el hash_table[Table_size]; |
|
|
init_hash() |
void init_hash() |
|
|
{ |
{ |
/* |
/* |
|
|
|
|
char *username(uid) |
char *username(uid) |
|
|
register int uid; |
register uid_t uid; |
|
|
{ |
{ |
register int hashindex; |
register int hashindex; |
|
|
return(hash_table[hashindex].name); |
return(hash_table[hashindex].name); |
} |
} |
|
|
int userid(username) |
uid_t userid(username) |
|
|
char *username; |
char *username; |
|
|
|
|
return(pwd->pw_uid); |
return(pwd->pw_uid); |
} |
} |
|
|
int enter_user(uid, name, wecare) |
static int enter_user(uid, name, wecare) |
|
|
register int uid; |
register uid_t uid; |
register char *name; |
register char *name; |
int wecare; /* 1 = enter it always, 0 = nice to have */ |
int wecare; /* 1 = enter it always, 0 = nice to have */ |
|
|
|
|
* and cache any entries we pass over while looking. |
* and cache any entries we pass over while looking. |
*/ |
*/ |
|
|
int get_user(uid) |
static int get_user(uid) |
|
|
register int uid; |
register uid_t uid; |
|
|
{ |
{ |
struct passwd *pwd; |
struct passwd *pwd; |