aboutsummaryrefslogtreecommitdiff
path: root/login/programs/utmpdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'login/programs/utmpdump.c')
-rw-r--r--login/programs/utmpdump.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/login/programs/utmpdump.c b/login/programs/utmpdump.c
new file mode 100644
index 0000000000..e1422b5028
--- /dev/null
+++ b/login/programs/utmpdump.c
@@ -0,0 +1,53 @@
+/* utmpdump - dump utmp-like files.
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <utmp.h>
+
+void
+print_entry (struct utmp *up)
+{
+ printf ("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-15.15s] [%ld]\n",
+ up->ut_type, up->ut_pid, up->ut_id, up->ut_user,
+ up->ut_line, 4 + ctime (&up->ut_time), up->ut_tv.tv_usec);
+}
+
+int
+main (int argc, char *argv[])
+{
+ struct utmp *up;
+
+ if (argc > 1)
+ utmpname (argv[1]);
+
+ setutent ();
+
+ while ((up = getutent ()))
+ print_entry (up);
+
+ endutent ();
+
+ return EXIT_SUCCESS;
+}