/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2009-2021 Todd C. Miller <[email protected]>4*5* Permission to use, copy, modify, and distribute this software for any6* purpose with or without fee is hereby granted, provided that the above7* copyright notice and this permission notice appear in all copies.8*9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.16*/1718#include <config.h>1920#include <stdio.h>21#include <time.h>2223#include <sudo_compat.h>24#include <sudo_debug.h>25#include <sudo_iolog.h>2627/*28* I/O log wrapper for fseek/gzseek.29*/30off_t31iolog_seek(struct iolog_file *iol, off_t offset, int whence)32{33off_t ret;34//debug_decl(iolog_seek, SUDO_DEBUG_UTIL);3536#ifdef HAVE_ZLIB_H37if (iol->compressed)38ret = gzseek(iol->fd.g, offset, whence);39else40#endif41ret = fseeko(iol->fd.f, offset, whence);4243//debug_return_off_t(ret);44return ret;45}4647/*48* I/O log wrapper for rewind/gzrewind.49*/50void51iolog_rewind(struct iolog_file *iol)52{53debug_decl(iolog_rewind, SUDO_DEBUG_UTIL);5455#ifdef HAVE_ZLIB_H56if (iol->compressed)57(void)gzrewind(iol->fd.g);58else59#endif60rewind(iol->fd.f);6162debug_return;63}646566