1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2001,2008 Oracle.  All rights reserved.
5 *
6 * $Id: os_ctime.c,v 12.16 2008/01/08 20:58:43 bostic Exp $
7 */
8
9#include "db_config.h"
10
11#include "db_int.h"
12
13/*
14 * __os_ctime --
15 *	Format a time-stamp.
16 *
17 * PUBLIC: char *__os_ctime __P((const time_t *, char *));
18 */
19char *
20__os_ctime(tod, time_buf)
21	const time_t *tod;
22	char *time_buf;
23{
24	time_buf[CTIME_BUFLEN - 1] = '\0';
25
26	/*
27	 * The ctime_r interface is the POSIX standard, thread-safe version of
28	 * ctime.  However, it was implemented in three different ways (with
29	 * and without a buffer length argument, and where the buffer length
30	 * argument was an int vs. a size_t *).  Also, you can't depend on a
31	 * return of (char *) from ctime_r, HP-UX 10.XX's version returned an
32	 * int.
33	 */
34#if defined(HAVE_VXWORKS)
35	{
36	size_t buflen = CTIME_BUFLEN;
37	(void)ctime_r(tod, time_buf, &buflen);
38	}
39#elif defined(HAVE_CTIME_R_3ARG)
40	(void)ctime_r(tod, time_buf, CTIME_BUFLEN);
41#elif defined(HAVE_CTIME_R)
42	(void)ctime_r(tod, time_buf);
43#else
44	(void)strncpy(time_buf, ctime(tod), CTIME_BUFLEN - 1);
45#endif
46	return (time_buf);
47}
48