Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/miscutils/last_fancy.c

    r3232 r3621  
    2323    INET6_ADDRSTRLEN, INET6_ADDRSTRLEN, "HOST", "LOGIN", "  TIME", ""
    2424
     25#if !defined __UT_LINESIZE && defined UT_LINESIZE
     26# define __UT_LINESIZE UT_LINESIZE
     27#endif
     28
    2529enum {
    2630    NORMAL,
     
    4044#define show_wide (option_mask32 & LAST_OPT_W)
    4145
    42 static void show_entry(struct utmp *ut, int state, time_t dur_secs)
     46static void show_entry(struct utmpx *ut, int state, time_t dur_secs)
    4347{
    4448    unsigned days, hours, mins;
    45     char duration[32];
     49    char duration[sizeof("(%u+02:02)") + sizeof(int)*3];
    4650    char login_time[17];
    4751    char logout_time[8];
     
    5458    tmp = ut->ut_tv.tv_sec;
    5559    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);
    5762
    5863    dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0);
     
    104109}
    105110
    106 static int get_ut_type(struct utmp *ut)
     111static int get_ut_type(struct utmpx *ut)
    107112{
    108113    if (ut->ut_line[0] == '~') {
     
    142147}
    143148
    144 static int is_runlevel_shutdown(struct utmp *ut)
     149static int is_runlevel_shutdown(struct utmpx *ut)
    145150{
    146151    if (((ut->ut_pid & 255) == '0') || ((ut->ut_pid & 255) == '6')) {
     
    154159int last_main(int argc UNUSED_PARAM, char **argv)
    155160{
    156     struct utmp ut;
     161    struct utmpx ut;
    157162    const char *filename = _PATH_WTMP;
    158163    llist_t *zlist;
     
    229234            }
    230235            /* add_entry */
    231             llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut)));
     236            llist_add_to(&zlist, xmemdup(&ut, sizeof(ut)));
    232237            break;
    233238        case USER_PROCESS: {
     
    242247                llist_t *el, *next;
    243248                for (el = zlist; el; el = next) {
    244                     struct utmp *up = (struct utmp *)el->data;
     249                    struct utmpx *up = (struct utmpx *)el->data;
    245250                    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) {
    247252                        if (show) {
    248253                            show_entry(&ut, NORMAL, up->ut_tv.tv_sec);
     
    271276            }
    272277            /* add_entry */
    273             llist_add_to(&zlist, memcpy(xmalloc(sizeof(ut)), &ut, sizeof(ut)));
     278            llist_add_to(&zlist, xmemdup(&ut, sizeof(ut)));
    274279            break;
    275280        }
Note: See TracChangeset for help on using the changeset viewer.