]> sourceware.org Git - glibc.git/blame - login/logout.c
update from main archive 961207
[glibc.git] / login / logout.c
CommitLineData
0200214b
RM
1/* Copyright (C) 1996 Free Software Foundation, Inc.
2This file is part of the GNU C Library.
3Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
1474b80f 4
0200214b
RM
5The GNU C Library is free software; you can redistribute it and/or
6modify it under the terms of the GNU Library General Public License as
7published by the Free Software Foundation; either version 2 of the
8License, or (at your option) any later version.
1474b80f 9
0200214b
RM
10The GNU C Library is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13Library General Public License for more details.
1474b80f 14
0200214b
RM
15You should have received a copy of the GNU Library General Public
16License along with the GNU C Library; see the file COPYING.LIB. If
17not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18Boston, 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
25int
0200214b 26logout (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}
This page took 0.06083 seconds and 5 git commands to generate.