/src/sudo/lib/iolog/iolog_eof.c
Line | Count | Source |
1 | | /* |
2 | | * SPDX-License-Identifier: ISC |
3 | | * |
4 | | * Copyright (c) 2009-2021 Todd C. Miller <Todd.Miller@sudo.ws> |
5 | | * |
6 | | * Permission to use, copy, modify, and distribute this software for any |
7 | | * purpose with or without fee is hereby granted, provided that the above |
8 | | * copyright notice and this permission notice appear in all copies. |
9 | | * |
10 | | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 | | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | | */ |
18 | | |
19 | | #include <config.h> |
20 | | |
21 | | #include <stdio.h> |
22 | | #ifdef HAVE_STDBOOL_H |
23 | | # include <stdbool.h> |
24 | | #else |
25 | | # include <compat/stdbool.h> |
26 | | #endif |
27 | | #include <time.h> |
28 | | |
29 | | #include <sudo_compat.h> |
30 | | #include <sudo_debug.h> |
31 | | #include <sudo_iolog.h> |
32 | | |
33 | | /* |
34 | | * Returns true if at end of I/O log file, else false. |
35 | | */ |
36 | | bool |
37 | | iolog_eof(struct iolog_file *iol) |
38 | 80 | { |
39 | 80 | bool ret; |
40 | 80 | debug_decl(iolog_eof, SUDO_DEBUG_UTIL); |
41 | | |
42 | | #ifdef HAVE_ZLIB_H |
43 | | if (iol->compressed) |
44 | | ret = gzeof(iol->fd.g) != 0; |
45 | | else |
46 | | #endif |
47 | 80 | ret = feof(iol->fd.f) != 0; |
48 | 80 | debug_return_int(ret); |
49 | 80 | } |