Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
b1447beb
...
b1447beb261d94b25472e24ba6b93ef2c32dea9e
authored
2002-05-02 12:30:31 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Replacements for {set,get,end}utent calls.
1 parent
1d9d8dbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
0 deletions
lib/utmp.c
lib/utmp.c
0 → 100644
View file @
b1447be
/* utmp.c -- Replacements for {set,get,end}utmp functions
Copyright (C) 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program 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
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include <utmp.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
static
char
*
utmp_name
=
_PATH_UTMP
;
static
int
fd
=
-
1
;
static
struct
utmp
ut
;
void
setutent
()
{
endutent
();
if
((
fd
=
open
(
utmp_name
,
O_RDWR
))
<
0
&&
((
fd
=
open
(
utmp_name
,
O_RDONLY
))
<
0
))
perror
(
"setutent: Can't open utmp file"
);
}
void
endutent
()
{
if
(
fd
>
0
)
close
(
fd
);
fd
=
-
1
;
}
struct
utmp
*
getutent
()
{
if
(
fd
<
0
)
setutent
();
if
(
fd
<
0
||
read
(
fd
,
&
ut
,
sizeof
ut
)
!=
sizeof
ut
)
return
NULL
;
return
&
ut
;
}
Please
register
or
sign in
to post a comment