# HG changeset patch # User Luis Felipe Strano Moraes # Date 1328574549 28800 # Node ID bc347fc87b004a4ddd9a5355c9e83f8258c82965 # Parent e134aebe79c11c464843e808c8e1797a0b256942 Initial version of who command. diff -r e134aebe79c1 -r bc347fc87b00 toys/who.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/who.c Mon Feb 06 16:29:09 2012 -0800 @@ -0,0 +1,38 @@ +/* vi: set sw=4 ts=4: + * + * who.c - display who is on the system + * + * Copyright 2012 ProFUSION Embedded Systems + * + * by Luis Felipe Strano Moraes + * + * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/who.html + +USE_WHO(NEWTOY(who, NULL, TOYFLAG_BIN)) + +config WHO + bool "who" + default y + help + usage: who + + Print logged user information on system + +*/ + +#include "toys.h" +#include + +void who_main(void) +{ + struct utmpx *entry; + + setutxent(); + + while ((entry = getutxent())) { + if (entry->ut_type == USER_PROCESS) + printf("%s %s (%s)\n", entry->ut_user, entry->ut_line, entry->ut_host); + } + + endutxent(); +}