/[machmon]/machmon/bsd/source/sys.c
ViewVC logotype

Diff of /machmon/bsd/source/sys.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pbastos, Mon Jul 8 01:26:09 2002 UTC revision 1.3 by pbastos, Tue Jul 9 15:02:47 2002 UTC
# Line 130  d_htnm(void) Line 130  d_htnm(void)
130  int  int
131  d_users(void)  d_users(void)
132  {  {
         char buf[16];  
133          int f, tmp, nusers = 0;          int f, tmp, nusers = 0;
134          time_t diff;          time_t diff;
135          struct utmp utmp_str;          struct utmp utmp_str;
         struct tm tm;  
136          FILE *utmp_file;          FILE *utmp_file;
137    
138          if (!(utmp_file = (FILE *) fopen(_PATH_UTMP, "r")))          if (!(utmp_file = (FILE *) fopen(_PATH_UTMP, "r")))
139                  return(1);                  return(1);
140    
         (void) memset(buf, 0, sizeof buf);  
141          (void) output("~WUsers logged on: ");          (void) output("~WUsers logged on: ");
142    
143          while (fread((char *) &utmp_str, sizeof(utmp_str), 1, utmp_file) == 1) {          while (fread((char *) &utmp_str, sizeof(utmp_str), 1, utmp_file) == 1) {
# Line 152  d_users(void) Line 149  d_users(void)
149                                  output("%-16s", " (local) ");                                  output("%-16s", " (local) ");
150                          else                          else
151                                  output(" from ~G%-16s~w ", utmp_str.ut_host);                                  output(" from ~G%-16s~w ", utmp_str.ut_host);
   
                         tm = *localtime(&utmp_str.ut_time);  
                         (void) strftime(buf, sizeof buf, "%H:%M, %d/%m", &tm);  
152                                                    
153                          diff = difftime(time(NULL), utmp_str.ut_time);                          diff = difftime(time(NULL), utmp_str.ut_time);
154                          tmp = (diff / SECSPERDAY);                          tmp = (diff / SECSPERDAY);

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

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26