Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/blacklist/bin/support.c
/* $NetBSD: support.c,v 1.8 2016/04/04 15:52:56 christos Exp $ */ | /* $NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $ */ | ||||
/*- | /*- | ||||
* Copyright (c) 2015 The NetBSD Foundation, Inc. | * Copyright (c) 2015 The NetBSD Foundation, Inc. | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* This code is derived from software contributed to The NetBSD Foundation | * This code is derived from software contributed to The NetBSD Foundation | ||||
* by Christos Zoulas. | * by Christos Zoulas. | ||||
* | * | ||||
Show All 18 Lines | |||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | ||||
*/ | */ | ||||
#ifdef HAVE_CONFIG_H | #ifdef HAVE_CONFIG_H | ||||
#include "config.h" | #include "config.h" | ||||
#endif | #endif | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__RCSID("$NetBSD: support.c,v 1.8 2016/04/04 15:52:56 christos Exp $"); | __RCSID("$NetBSD: support.c,v 1.9 2018/09/18 22:12:19 christos Exp $"); | ||||
#include <time.h> | #include <time.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <inttypes.h> | #include <inttypes.h> | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | |||||
fmtydhms(char *b, size_t l, time_t t) | fmtydhms(char *b, size_t l, time_t t) | ||||
{ | { | ||||
time_t s, m, h, d, y; | time_t s, m, h, d, y; | ||||
int z; | int z; | ||||
size_t o; | size_t o; | ||||
s = t % 60; | s = t % 60; | ||||
t /= 60; | t /= 60; | ||||
m = t % 60; | m = t % 60; | ||||
t /= 60; | t /= 60; | ||||
h = t % 60; | |||||
h = t % 24; | |||||
t /= 24; | t /= 24; | ||||
d = t % 24; | |||||
t /= 356; | d = t % 365; | ||||
t /= 365; | |||||
y = t; | y = t; | ||||
z = 0; | z = 0; | ||||
o = 0; | o = 0; | ||||
#define APPEND(a) \ | #define APPEND(a) \ | ||||
if (a) { \ | if (a) { \ | ||||
z = snprintf(b + o, l - o, "%jd%s", (intmax_t)a, __STRING(a)); \ | z = snprintf(b + o, l - o, "%jd%s", (intmax_t)a, __STRING(a)); \ | ||||
if (z == -1) \ | if (z == -1) \ | ||||
Show All 36 Lines |