1 /* vi: set sw=4 ts=4: */
3 * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
6 * Takes utmp formated file on stdin and dumps it's contents
7 * out in colon delimited fields. Easy to 'cut' for shell based
8 * versions of 'who', 'last', etc. IP Addr is output in hex,
9 * little endian on x86.
11 * Modified to support all sort of libcs by
12 * Erik Andersen <andersen@lineo.com>
16 #include <sys/types.h>
21 #define BB_DECLARE_EXTERN
22 #define bb_need_io_error
27 static const char dutmp_usage[] = "dutmp [FILE]\n"
28 #ifndef BB_FEATURE_TRIVIAL_HELP
29 "\nDump utmp file format (pipe delimited) from FILE\n"
30 "or stdin to stdout. (i.e. 'dutmp /var/run/utmp')\n"
34 extern int dutmp_main(int argc, char **argv)
42 } else if (*argv[1] == '-' ) {
45 file = open(argv[1], O_RDONLY);
47 fatalError(io_error, argv[1], strerror(errno));
51 while (read(file, (void*)&ut, sizeof(struct utmp))) {
52 printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
53 ut.ut_type, ut.ut_pid, ut.ut_line,
54 ut.ut_id, ut.ut_user, ut.ut_host,