Back to index

glibc  2.9
getutmpx.c
Go to the documentation of this file.
00001 /* Copyright (C) 1999 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <string.h>
00020 #include <utmp.h>
00021 #include <utmpx.h>
00022 
00023 /* Copy the information in UTMP to UTMPX. */
00024 void
00025 getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
00026 {
00027   memset (utmpx, 0, sizeof (struct utmpx));
00028 
00029 #if _HAVE_UT_TYPE - 0
00030   utmpx->ut_type = utmp->ut_type;
00031 #endif
00032 #if _HAVE_UT_PID - 0
00033   utmpx->ut_pid = utmp->ut_pid;
00034 #endif
00035   memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
00036   memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
00037 #if _HAVE_UT_ID - 0
00038   memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
00039 #endif
00040 #if _HAVE_UT_HOST - 0
00041   memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
00042 #endif
00043 #if _HAVE_UT_TV - 0
00044   utmpx->ut_tv = utmp->ut_tv;
00045 #else
00046   utmpx->ut_time = utmp->ut_time;
00047 #endif
00048 }