- while (fread (&ut, 1, sizeof (struct utmp), f)) {
- // printf("%d:%d:%s:%s:%s:%s:%d:%d:%ld:%ld:%ld:%x\n",
- printf ("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",
+/* Kludge around the fact that the binary format for utmp has changed. */
+#if __GNU_LIBRARY__ < 5
+ /* Linux libc5 */
+ while (read(file, (void*)&ut, sizeof(struct utmp))) {
+ printf("%d|%d|%s|%s|%s|%s|%s|%lx\n",
+ ut.ut_type, ut.ut_pid, ut.ut_line,
+ ut.ut_id, ut.ut_user, ut.ut_host,
+ ctime(&(ut.ut_time)),
+ (long)ut.ut_addr);
+ }
+#else
+ /* Glibc, uClibc, etc. */
+ while (read(file, (void*)&ut, sizeof(struct utmp))) {
+ printf("%d|%d|%s|%s|%s|%s|%d|%d|%ld|%ld|%ld|%x\n",