2 * "THE BEER-WARE LICENSE" (Revision 42):
3 * <tobias.rehbein@web.de> wrote this file. As long as you retain this notice
4 * you can do whatever you want with this stuff. If we meet some day, and you
5 * think this stuff is worth it, you can buy me a beer in return.
18 struct clock_context
{
19 char clock_str
[CLOCK_BUFFLEN
];
22 struct clock_context
*
25 struct clock_context
*ctx
;
27 if ((ctx
= malloc(sizeof(*ctx
))) == NULL
)
28 err(EX_SOFTWARE
, "malloc(%d) clock_context", sizeof(struct clock_context
));
34 clock_context_close(struct clock_context
*ctx
)
42 clock_str(struct clock_context
*ctx
)
49 if (time(&t
) == (time_t) (-1))
50 errx(EX_SOFTWARE
, "time()");
51 if ((tm
= localtime(&t
)) == NULL
)
52 errx(EX_SOFTWARE
, "localtime()");
54 strftime(ctx
->clock_str
, sizeof(ctx
->clock_str
), "%c", tm
);
56 return (ctx
->clock_str
);