glibc/login/getutid_r.c
Ulrich Drepper b2637a22db Update.
2004-01-14  Ulrich Drepper  <drepper@redhat.com>

	* libio/libio.h: Add const to function tables types.
	* libio/libioP.h: Likewise.
	* /login/utmp-private.h: Likewise.
	* libio/fileops.c: Add const to jump table variable definition.
	* libio/genops.c: Likewise.
	* libio/iofopncook.c: Likewise.
	* libio/iopopen.c: Likewise.
	* libio/memstream.c: Likewise.
	* libio/obprintf.c: Likewise.
	* libio/oldfileops.c: Likewise.
	* libio/oldiopopen.c: Likewise.
	* libio/strops.c: Likewise.
	* libio/vsnprintf.c: Likewise.
	* libio/vswprintf.c: Likewise.
	* libio/wfileops.c: Likewise.
	* libio/wstrops.c: Likewise.
	* login/getutent_r.c: Likewise.
	* login/getutid_r.c Likewise.
	* login/getutline_r.c: Likewise.
	* sysdeps/generic/utmp_file.c: Likewise.
2004-01-14 18:41:22 +00:00

64 lines
2.0 KiB
C

/* Copyright (C) 1996, 1997, 2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>
and Paul Janzen <pcj@primenet.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <bits/libc-lock.h>
#include <errno.h>
#include <stdlib.h>
#include <utmp.h>
#include "utmp-private.h"
/* We have to use the lock in getutent_r.c. */
__libc_lock_define (extern, __libc_utmp_lock attribute_hidden)
int
__getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
{
#if (_HAVE_UT_ID - 0) && (_HAVE_UT_TYPE - 0)
int retval;
/* Test whether ID has any of the legal types. */
if (id->ut_type != RUN_LVL && id->ut_type != BOOT_TIME
&& id->ut_type != OLD_TIME && id->ut_type != NEW_TIME
&& id->ut_type != INIT_PROCESS && id->ut_type != LOGIN_PROCESS
&& id->ut_type != USER_PROCESS && id->ut_type != DEAD_PROCESS)
/* No, using '<' and '>' for the test is not possible. */
{
__set_errno (EINVAL);
*result = NULL;
return -1;
}
__libc_lock_lock (__libc_utmp_lock);
retval = (*__libc_utmp_jump_table->getutid_r) (id, buffer, result);
__libc_lock_unlock (__libc_utmp_lock);
return retval;
#else /* !_HAVE_UT_ID && !_HAVE_UT_TYPE */
__set_errno (ENOSYS);
return -1;
#endif
}
weak_alias (__getutid_r, getutid_r)