2 * public domain -- Dave 'Kill a Cop' Cinege <dcinege@psychosis.com>
5 * Takes utmp formated file on stdin and dumps it's contents
6 * out in colon delimited fields. Easy to 'cut' for shell based
7 * versions of 'who', 'last', etc. IP Addr is output in hex,
8 * little endian on x86.
17 const char dutmp_usage[] = "dutmp\n"
19 "\tDump file or stdin utmp file format to stdout, pipe delimited.\n"
20 "\tdutmp /var/run/utmp\n";
23 dutmp_fn(const struct FileInfo * i)
27 struct utmp * ut = (struct utmp *) malloc(sizeof(struct utmp) );
30 if (! (f = fopen(i->source, "r"))) {
31 name_and_error(i->source);
35 while (fread (ut, 1, sizeof(struct utmp), f)) {
36 //printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
37 printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
38 ut->ut_type, ut->ut_pid, ut->ut_line,
39 ut->ut_id, ut->ut_user, ut->ut_host,
40 ut->ut_exit.e_termination, ut->ut_exit.e_exit,
42 ut->ut_tv.tv_sec, ut->ut_tv.tv_usec,