diff options
Diffstat (limited to 'miscutils/last_fancy.c')
-rw-r--r-- | miscutils/last_fancy.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index 16ed9e920..8194e31b5 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c | |||
@@ -22,6 +22,10 @@ | |||
22 | #define HEADER_LINE_WIDE "USER", "TTY", \ | 22 | #define HEADER_LINE_WIDE "USER", "TTY", \ |
23 | INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" | 23 | INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", " TIME", "" |
24 | 24 | ||
25 | #if !defined __UT_LINESIZE && defined UT_LINESIZE | ||
26 | # define __UT_LINESIZE UT_LINESIZE | ||
27 | #endif | ||
28 | |||
25 | enum { | 29 | enum { |
26 | NORMAL, | 30 | NORMAL, |
27 | LOGGED, | 31 | LOGGED, |
@@ -39,7 +43,7 @@ enum { | |||
39 | 43 | ||
40 | #define show_wide (option_mask32 & LAST_OPT_W) | 44 | #define show_wide (option_mask32 & LAST_OPT_W) |
41 | 45 | ||
42 | static void show_entry(struct utmp *ut, int state, time_t dur_secs) | 46 | static void show_entry(struct utmpx *ut, int state, time_t dur_secs) |
43 | { | 47 | { |
44 | unsigned days, hours, mins; | 48 | unsigned days, hours, mins; |
45 | char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; | 49 | char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; |
@@ -104,7 +108,7 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) | |||
104 | duration_str); | 108 | duration_str); |
105 | } | 109 | } |
106 | 110 | ||
107 | static int get_ut_type(struct utmp *ut) | 111 | static int get_ut_type(struct utmpx *ut) |
108 | { | 112 | { |
109 | if (ut->ut_line[0] == '~') { | 113 | if (ut->ut_line[0] == '~') { |
110 | if (strcmp(ut->ut_user, "shutdown") == 0) { | 114 | if (strcmp(ut->ut_user, "shutdown") == 0) { |
@@ -142,7 +146,7 @@ static int get_ut_type(struct utmp *ut) | |||
142 | return ut->ut_type; | 146 | return ut->ut_type; |
143 | } | 147 | } |
144 | 148 | ||
145 | static int is_runlevel_shutdown(struct utmp *ut) | 149 | static int is_runlevel_shutdown(struct utmpx *ut) |
146 | { | 150 | { |
147 | if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { | 151 | if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { |
148 | return 1; | 152 | return 1; |
@@ -154,7 +158,7 @@ static int is_runlevel_shutdown(struct utmp *ut) | |||
154 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 158 | int last_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
155 | int last_main(int argc UNUSED_PARAM, char **argv) | 159 | int last_main(int argc UNUSED_PARAM, char **argv) |
156 | { | 160 | { |
157 | struct utmp ut; | 161 | struct utmpx ut; |
158 | const char *filename = _PATH_WTMP; | 162 | const char *filename = _PATH_WTMP; |
159 | llist_t *zlist; | 163 | llist_t *zlist; |
160 | off_t pos; | 164 | off_t pos; |
@@ -242,9 +246,9 @@ int last_main(int argc UNUSED_PARAM, char **argv) | |||
242 | { | 246 | { |
243 | llist_t *el, *next; | 247 | llist_t *el, *next; |
244 | for (el = zlist; el; el = next) { | 248 | for (el = zlist; el; el = next) { |
245 | struct utmp *up = (struct utmp *)el->data; | 249 | struct utmpx *up = (struct utmpx *)el->data; |
246 | next = el->link; | 250 | next = el->link; |
247 | if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) { | 251 | if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) { |
248 | if (show) { | 252 | if (show) { |
249 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); | 253 | show_entry(&ut, NORMAL, up->ut_tv.tv_sec); |
250 | show = 0; | 254 | show = 0; |