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

Diff for /src/usr.bin/rusers/rusers.c between version 1.18 and 1.19

version 1.18, 2001/11/06 20:51:19 version 1.19, 2001/11/07 00:02:58
Line 97 
Line 97 
 void onehost(char *);  void onehost(char *);
 void allhosts(void);  void allhosts(void);
 void sorthosts(void);  void sorthosts(void);
   void expandhosts(void);
 void alarmclock(int);  void alarmclock(int);
 char *estrndup(const char *, size_t);  char *estrndup(const char *, size_t);
 struct host_info *add_host(char *);  struct host_info *add_host(char *);
Line 672 
Line 673 
 }  }
   
 void  void
   expandhosts()
   {
           struct host_info *new_hostinfo, *entry;
           u_int count;
           int i, j;
   
           for (i = 0, count = 0; i < nentries; i++)
                   count += hostinfo[i].count;
   
           new_hostinfo = (struct host_info *)malloc(sizeof(*entry) * count);
           if (new_hostinfo == NULL)
                   err(1, NULL);
           for (i = 0, entry = new_hostinfo; i < nentries; i++) {
                   for (j = 0; j < hostinfo[i].count; j++) {
                           memcpy(entry, &hostinfo[i], sizeof(*entry));
                           entry->users = &hostinfo[i].users[j];
                           entry->idle = entry->users->ut_idle;
                           entry->count = 1;
                           entry++;
                   }
           }
           free(hostinfo);
           hostinfo = new_hostinfo;
           nentries = maxentries = count;
   }
   
   void
 sorthosts()  sorthosts()
 {  {
         int i;          int i;
         int (*compar)(const void *, const void *);          int (*compar)(const void *, const void *);
   
           if (iflag && lflag)
                   expandhosts();
   
         if (hflag)          if (hflag)
                 compar = hcompare;                  compar = hcompare;

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19