aboutsummaryrefslogtreecommitdiff
path: root/miscutils/last_fancy.c
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-01 10:10:22 +0000
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2008-06-01 10:10:22 +0000
commit62d85035895152c8232052dcfb1bbd3b549b7df9 (patch)
tree49c794fe1f2b108ddf394f6d0263d04b6a0973f5 /miscutils/last_fancy.c
parente0fd13e901253c5742f1e80778e149a0a07dc874 (diff)
downloadbusybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.tar.gz
busybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.tar.bz2
busybox-w32-62d85035895152c8232052dcfb1bbd3b549b7df9.zip
- use ut_user rather than ut_name (Cristian Ionescu-Idbohrn)
- use ut_tv.tv_sec rather than ut_time (me) - shrink halt a little bit (me): halt_main 464 433 -31 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-31) Total: -31 bytes
Diffstat (limited to 'miscutils/last_fancy.c')
-rw-r--r--miscutils/last_fancy.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c
index d234a48bf..0dba9dca7 100644
--- a/miscutils/last_fancy.c
+++ b/miscutils/last_fancy.c
@@ -46,7 +46,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs)
46 const char *logout_str; 46 const char *logout_str;
47 const char *duration_str; 47 const char *duration_str;
48 48
49 safe_strncpy(login_time, ctime(&(ut->ut_time)), 17); 49 safe_strncpy(login_time, ctime(&(ut->ut_tv.tv_sec)), 17);
50 snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); 50 snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11);
51 51
52 dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); 52 dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0);
@@ -87,7 +87,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs)
87 } 87 }
88 88
89 printf(HEADER_FORMAT, 89 printf(HEADER_FORMAT,
90 ut->ut_name, 90 ut->ut_user,
91 ut->ut_line, 91 ut->ut_line,
92 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, 92 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
93 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN, 93 show_wide ? INET6_ADDRSTRLEN : INET_ADDRSTRLEN,
@@ -112,19 +112,19 @@ static int get_ut_type(struct utmp *ut)
112 return ut->ut_type; 112 return ut->ut_type;
113 } 113 }
114 114
115 if (ut->ut_name[0] == 0) { 115 if (ut->ut_user[0] == 0) {
116 return DEAD_PROCESS; 116 return DEAD_PROCESS;
117 } 117 }
118 118
119 if ((ut->ut_type != DEAD_PROCESS) 119 if ((ut->ut_type != DEAD_PROCESS)
120 && (strcmp(ut->ut_name, "LOGIN") != 0) 120 && (strcmp(ut->ut_user, "LOGIN") != 0)
121 && ut->ut_name[0] 121 && ut->ut_user[0]
122 && ut->ut_line[0] 122 && ut->ut_line[0]
123 ) { 123 ) {
124 ut->ut_type = USER_PROCESS; 124 ut->ut_type = USER_PROCESS;
125 } 125 }
126 126
127 if (strcmp(ut->ut_name, "date") == 0) { 127 if (strcmp(ut->ut_user, "date") == 0) {
128 if (ut->ut_line[0] == '|') { 128 if (ut->ut_line[0] == '|') {
129 return OLD_TIME; 129 return OLD_TIME;
130 } 130 }
@@ -196,18 +196,18 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv)
196 xlseek(file, pos, SEEK_SET); 196 xlseek(file, pos, SEEK_SET);
197 xread(file, &ut, sizeof(ut)); 197 xread(file, &ut, sizeof(ut));
198 /* rewritten by each record, eventially will have 198 /* rewritten by each record, eventially will have
199 * first record's ut_time: */ 199 * first record's ut_tv.tv_sec: */
200 start_time = ut.ut_time; 200 start_time = ut.ut_tv.tv_sec;
201 201
202 switch (get_ut_type(&ut)) { 202 switch (get_ut_type(&ut)) {
203 case SHUTDOWN_TIME: 203 case SHUTDOWN_TIME:
204 down_time = ut.ut_time; 204 down_time = ut.ut_tv.tv_sec;
205 boot_down = DOWN; 205 boot_down = DOWN;
206 going_down = 1; 206 going_down = 1;
207 break; 207 break;
208 case RUN_LVL: 208 case RUN_LVL:
209 if (is_runlevel_shutdown(&ut)) { 209 if (is_runlevel_shutdown(&ut)) {
210 down_time = ut.ut_time; 210 down_time = ut.ut_tv.tv_sec;
211 going_down = 1; 211 going_down = 1;
212 boot_down = DOWN; 212 boot_down = DOWN;
213 } 213 }
@@ -240,7 +240,7 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv)
240 next = el->link; 240 next = el->link;
241 if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { 241 if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) {
242 if (show) { 242 if (show) {
243 show_entry(&ut, NORMAL, up->ut_time); 243 show_entry(&ut, NORMAL, up->ut_tv.tv_sec);
244 show = 0; 244 show = 0;
245 } 245 }
246 llist_unlink(&zlist, el); 246 llist_unlink(&zlist, el);
@@ -271,7 +271,7 @@ int last_main(int argc ATTRIBUTE_UNUSED, char **argv)
271 } 271 }
272 272
273 if (going_down) { 273 if (going_down) {
274 boot_time = ut.ut_time; 274 boot_time = ut.ut_tv.tv_sec;
275 llist_free(zlist, free); 275 llist_free(zlist, free);
276 zlist = NULL; 276 zlist = NULL;
277 going_down = 0; 277 going_down = 0;