[BACK]Return to username.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/Attic/username.c between version 1.1 and 1.2

version 1.1, 1997/08/14 14:00:27 version 1.2, 1997/08/22 07:16:31
Line 30 
Line 30 
  *  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 */
Line 53 
Line 58 
 /* 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()
   
 {  {
     /*      /*
Line 65 
Line 70 
   
 char *username(uid)  char *username(uid)
   
 register int uid;  register uid_t uid;
   
 {  {
     register int hashindex;      register int hashindex;
Line 79 
Line 84 
     return(hash_table[hashindex].name);      return(hash_table[hashindex].name);
 }  }
   
 int userid(username)  uid_t userid(username)
   
 char *username;  char *username;
   
Line 102 
Line 107 
     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 */
   
Line 138 
Line 143 
  * 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;

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2