]>
Commit | Line | Data |
---|---|---|
c84142e8 UD |
1 | /* Copyright (C) 1996, 1997 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. | |
3 | Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. | |
1474b80f | 4 | |
c84142e8 UD |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
1474b80f | 9 | |
c84142e8 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
1474b80f | 14 | |
c84142e8 UD |
15 | You should have received a copy of the GNU Library General Public |
16 | License along with the GNU C Library; see the file COPYING.LIB. If not, | |
17 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
18 | Boston, MA 02111-1307, USA. */ | |
1474b80f | 19 | |
0200214b RM |
20 | #include <errno.h> |
21 | #include <string.h> | |
22 | #include <utmp.h> | |
23 | #include <sys/time.h> | |
1474b80f RM |
24 | |
25 | int | |
0200214b | 26 | logout (const char *line) |
1474b80f | 27 | { |
8a523922 | 28 | struct utmp tmp, utbuf; |
0200214b RM |
29 | struct utmp *ut; |
30 | int result = 0; | |
31 | ||
32 | /* Tell that we want to use the UTMP file. */ | |
33 | if (utmpname (_PATH_UTMP) == 0) | |
34 | return 0; | |
35 | ||
36 | /* Open UTMP file. */ | |
8a523922 | 37 | setutent (); |
0200214b RM |
38 | |
39 | /* Fill in search information. */ | |
40 | #if _HAVE_UT_TYPE - 0 | |
41 | tmp.ut_type = USER_PROCESS; | |
42 | #endif | |
4f54cdb1 | 43 | strncpy (tmp.ut_line, line, sizeof tmp.ut_line); |
0200214b RM |
44 | |
45 | /* Read the record. */ | |
8a523922 | 46 | if (getutline_r (&tmp, &utbuf, &ut) >= 0) |
0200214b RM |
47 | { |
48 | /* Clear information about who & from where. */ | |
4f54cdb1 RM |
49 | bzero (ut->ut_name, sizeof ut->ut_name); |
50 | #if _HAVE_UT_HOST - 0 | |
51 | bzero (ut->ut_host, sizeof ut->ut_host); | |
52 | #endif | |
0200214b RM |
53 | #if _HAVE_UT_TV - 0 |
54 | gettimeofday (&ut->ut_tv, NULL); | |
55 | #else | |
56 | time (&ut->ut_time); | |
57 | #endif | |
58 | ||
8a523922 | 59 | if (pututline (ut) >= 0) |
0200214b RM |
60 | result = 1; |
61 | } | |
62 | ||
63 | /* Close UTMP file. */ | |
8a523922 | 64 | endutent (); |
1474b80f | 65 | |
0200214b | 66 | return result; |
1474b80f | 67 | } |