1 /* Copyright (C) 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@cygnus.com>
4 and Paul Janzen <pcj@primenet.com>, 1996.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 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 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
30 #include "utmp-private.h"
33 /* This is the default name. */
34 static const char default_file_name
[] = _PATH_UTMP_DB
;
36 /* Current file name. */
37 static const char *file_name
= (const char *) default_file_name
;
39 /* Descriptor for database. */
41 /* XXX One day this will become meaningful again. */
43 static char last_date
[16];
46 /* Our local functions. */
47 static int setutent_db (int reset
);
48 static void endutent_db (void);
49 static int utmpname_db (const char *name
);
52 /* The jump table for the local functions. */
53 struct utfuncs __libc_utmp_db_functions
=
66 setutent_db (int reset
)
79 utmpname_db (const char *name
)
81 if (strcmp (name
, file_name
) != 0)
83 if (strcmp (name
, default_file_name
) == 0)
85 if (file_name
!= default_file_name
)
86 free ((char *) file_name
);
88 file_name
= default_file_name
;
92 char *new_name
= __strdup (name
);
97 if (file_name
!= default_file_name
)
98 free ((char *) file_name
);
100 file_name
= new_name
;