1 /* utmpdump - dump utmp-like files.
2 Copyright (C) 1997-2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
27 print_entry (struct utmp
*up
)
29 /* Mixed 32-/64-bit systems may have timeval structs of different sixe
30 but need struct utmp to be the same size. So in 64-bit up->ut_tv may
31 not be a timeval but a struct of __int32_t's. This would cause a compile
32 time warning and a formating error when 32-bit int is passed where
33 a 64-bit long is expected. So copy up->up_tv to a temporary timeval.
34 This is 32-/64-bit agnostic and expands the timeval fields to the
35 expected size as needed. */
36 struct timeval temp_tv
;
37 temp_tv
.tv_sec
= up
->ut_tv
.tv_sec
;
38 temp_tv
.tv_usec
= up
->ut_tv
.tv_usec
;
41 /* The format string. */
70 , up
->ut_user
, up
->ut_line
75 , 4 + ctime (&temp_tv
.tv_sec
)
76 , (long int) temp_tv
.tv_usec
78 , 4 + ctime (&up
->ut_time
)
84 main (int argc
, char *argv
[])
93 while ((up
= getutent ()))