Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/miscutils/last_fancy.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/miscutils/last_fancy.c
r3232 r3621 23 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 29 enum { 26 30 NORMAL, … … 40 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 48 unsigned days, hours, mins; 45 char duration[ 32];49 char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; 46 50 char login_time[17]; 47 51 char logout_time[8]; … … 54 58 tmp = ut->ut_tv.tv_sec; 55 59 safe_strncpy(login_time, ctime(&tmp), 17); 56 snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); 60 tmp = dur_secs; 61 snprintf(logout_time, 8, "- %s", ctime(&tmp) + 11); 57 62 58 63 dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); … … 104 109 } 105 110 106 static int get_ut_type(struct utmp *ut)111 static int get_ut_type(struct utmpx *ut) 107 112 { 108 113 if (ut->ut_line[0] == '~') { … … 142 147 } 143 148 144 static int is_runlevel_shutdown(struct utmp *ut)149 static int is_runlevel_shutdown(struct utmpx *ut) 145 150 { 146 151 if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) { … … 154 159 int last_main(int argc UNUSED_PARAM, char **argv) 155 160 { 156 struct utmp ut;161 struct utmpx ut; 157 162 const char *filename = _PATH_WTMP; 158 163 llist_t *zlist; … … 229 234 } 230 235 /* add_entry */ 231 llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)),&ut, sizeof(ut)));236 llist_add_to(&zlist, xmemdup(&ut, sizeof(ut))); 232 237 break; 233 238 case USER_PROCESS: { … … 242 247 llist_t *el, *next; 243 248 for (el = zlist; el; el = next) { 244 struct utmp *up = (struct utmp*)el->data;249 struct utmpx *up = (struct utmpx *)el->data; 245 250 next = el->link; 246 if (strncmp(up->ut_line, ut.ut_line, UT_LINESIZE) == 0) {251 if (strncmp(up->ut_line, ut.ut_line, __UT_LINESIZE) == 0) { 247 252 if (show) { 248 253 show_entry(&ut, NORMAL, up->ut_tv.tv_sec); … … 271 276 } 272 277 /* add_entry */ 273 llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)),&ut, sizeof(ut)));278 llist_add_to(&zlist, xmemdup(&ut, sizeof(ut))); 274 279 break; 275 280 }
Note:
See TracChangeset
for help on using the changeset viewer.