/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 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#ifndef HAVE_LOCALTIME_R2122#include <sys/types.h>23#include <time.h>2425#include <sudo_compat.h>26#include <sudo_util.h>2728/*29* Fake localtime_r() that just stores the result.30* Still has the normal localtime() side effects.31*/32struct tm *33sudo_localtime_r(const time_t * restrict timer, struct tm * restrict result)34{35struct tm *tm;3637if ((tm = localtime(timer)) == NULL)38return NULL;39memcpy(result, tm, sizeof(struct tm));4041return result;42}43#endif /* HAVE_LOCALTIME_T */444546