Back to index

glibc  2.9
utmp-equal.h
Go to the documentation of this file.
00001 /* Helper function for utmp functions to see if two entries are equal.
00002    Copyright (C) 1996,97,98,99,2000,01,02 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>
00005    and Paul Janzen <pcj@primenet.com>, 1996.
00006 
00007    The GNU C Library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Lesser General Public
00009    License as published by the Free Software Foundation; either
00010    version 2.1 of the License, or (at your option) any later version.
00011 
00012    The GNU C Library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Lesser General Public License for more details.
00016 
00017    You should have received a copy of the GNU Lesser General Public
00018    License along with the GNU C Library; if not, write to the Free
00019    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00020    02111-1307 USA.  */
00021 
00022 #include <string.h>
00023 #include <utmp.h>
00024 
00025 #include "utmp-private.h"
00026 
00027 /* Test whether two entries match.  */
00028 static int
00029 __utmp_equal (const struct utmp *entry, const struct utmp *match)
00030 {
00031   return
00032     (
00033 #if _HAVE_UT_TYPE - 0
00034      (entry->ut_type == INIT_PROCESS
00035       || entry->ut_type == LOGIN_PROCESS
00036       || entry->ut_type == USER_PROCESS
00037       || entry->ut_type == DEAD_PROCESS)
00038      &&
00039      (match->ut_type == INIT_PROCESS
00040       || match->ut_type == LOGIN_PROCESS
00041       || match->ut_type == USER_PROCESS
00042       || match->ut_type == DEAD_PROCESS)
00043      &&
00044 #endif
00045 #if _HAVE_UT_ID - 0
00046      (entry->ut_id[0] && match->ut_id[0]
00047       ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0
00048       : strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0)
00049 #else
00050      strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0
00051 #endif
00052      );
00053 }