diff options
author | Luis Felipe Strano Moraes <lfelipe@profusion.mobi> | 2012-02-07 09:15:17 -0800 |
---|---|---|
committer | Luis Felipe Strano Moraes <lfelipe@profusion.mobi> | 2012-02-07 09:15:17 -0800 |
commit | 0352f4257da11908b211d704a9ef38e0055711e5 (patch) | |
tree | c895a1498039aca73e0459fe1f6c7bba792c9fbf | |
parent | 5232ac079353fb3779e480b74e87c714af6ee707 (diff) | |
download | toybox-0352f4257da11908b211d704a9ef38e0055711e5.tar.gz |
Added time to the output of who command.
-rw-r--r-- | toys/who.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -21,6 +21,7 @@ config WHO */ #include "toys.h" +#include <time.h> #include <utmpx.h> void who_main(void) @@ -30,8 +31,17 @@ void who_main(void) setutxent(); while ((entry = getutxent())) { - if (entry->ut_type == USER_PROCESS) - printf("%s %s (%s)\n", entry->ut_user, entry->ut_line, entry->ut_host); + if (entry->ut_type == USER_PROCESS) { + time_t time; + int time_size; + char * times; + + time = entry->ut_tv.tv_sec; + times = ctime(&time); + time_size = strlen(times) - 2; + printf("%s\t%s\t%*.*s\t(%s)\n", entry->ut_user, entry->ut_line, time_size, time_size, ctime(&time), entry->ut_host); + + } } endutxent(); |