| 1 | /* Helper function for utmp functions to see if two entries are equal. | 
|---|
| 2 | Copyright (C) 1996-2020 Free Software Foundation, Inc. | 
|---|
| 3 | This file is part of the GNU C Library. | 
|---|
| 4 | Contributed by Ulrich Drepper <drepper@cygnus.com> | 
|---|
| 5 | and Paul Janzen <pcj@primenet.com>, 1996. | 
|---|
| 6 |  | 
|---|
| 7 | The GNU C Library is free software; you can redistribute it and/or | 
|---|
| 8 | modify it under the terms of the GNU Lesser General Public | 
|---|
| 9 | License as published by the Free Software Foundation; either | 
|---|
| 10 | version 2.1 of the License, or (at your option) any later version. | 
|---|
| 11 |  | 
|---|
| 12 | The GNU C Library is distributed in the hope that it will be useful, | 
|---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 15 | Lesser General Public License for more details. | 
|---|
| 16 |  | 
|---|
| 17 | You should have received a copy of the GNU Lesser General Public | 
|---|
| 18 | License along with the GNU C Library; if not, see | 
|---|
| 19 | <https://www.gnu.org/licenses/>.  */ | 
|---|
| 20 |  | 
|---|
| 21 | #include <string.h> | 
|---|
| 22 | #include <utmp.h> | 
|---|
| 23 |  | 
|---|
| 24 | #include "utmp-private.h" | 
|---|
| 25 |  | 
|---|
| 26 | /* Test whether two entries match.  */ | 
|---|
| 27 | static int | 
|---|
| 28 | __utmp_equal (const struct utmp *entry, const struct utmp *match) | 
|---|
| 29 | { | 
|---|
| 30 | return (entry->ut_type == INIT_PROCESS | 
|---|
| 31 | || entry->ut_type == LOGIN_PROCESS | 
|---|
| 32 | || entry->ut_type == USER_PROCESS | 
|---|
| 33 | || entry->ut_type == DEAD_PROCESS) | 
|---|
| 34 | && (match->ut_type == INIT_PROCESS | 
|---|
| 35 | || match->ut_type == LOGIN_PROCESS | 
|---|
| 36 | || match->ut_type == USER_PROCESS | 
|---|
| 37 | || match->ut_type == DEAD_PROCESS) | 
|---|
| 38 | && (entry->ut_id[0] && match->ut_id[0] | 
|---|
| 39 | ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0 | 
|---|
| 40 | : (strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) | 
|---|
| 41 | == 0)); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|