2 * utmpdump Simple program to dump UTMP and WTMP files in
3 * raw format, so they can be examined.
5 * Version: @(#)utmpdump.c 13-Aug-1996 1.00 miquels@cistron.nl
7 * This file is part of the sysvinit suite,
8 * Copyright (C) 1991-1996 Miquel van Smoorenburg.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36 while (fread(&ut, sizeof(struct utmp), 1, fp) == 1) {
37 for(f = 0; f < 12; f++) if (ut.ut_line[f] == ' ') ut.ut_line[f] = '_';
38 for(f = 0; f < 8; f++) if (ut.ut_name[f] == ' ') ut.ut_name[f] = '_';
40 printf("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-15.15s]\n",
41 ut.ut_type, ut.ut_pid, ut.ut_id, ut.ut_user,
42 ut.ut_line, 4 + ctime(&tm));
58 for(f = 1; f < argc; f++) {
59 if (strcmp(argv[f], "-") == 0) {
60 printf("Utmp dump of stdin\n");
62 } else if ((fp = fopen(argv[f], "r")) != NULL) {
63 printf("Utmp dump of %s\n", argv[f]);