1 /* taken from ldns 1.6.1 */
6 #include "util/locks.h"
8 /** the lock for ctime buffer */
9 static lock_basic_type ctime_lock;
10 /** has it been inited */
11 static int ctime_r_init = 0;
13 /** cleanup ctime_r on exit */
19 lock_basic_destroy(&ctime_lock);
23 char *ctime_r(const time_t *timep, char *buf)
27 /* still small race where this init can be done twice,
28 * which is mostly harmless */
30 lock_basic_init(&ctime_lock);
31 atexit(&ctime_r_cleanup);
33 lock_basic_lock(&ctime_lock);
34 result = ctime(timep);
36 if(strlen(result) > 10 && result[7]==' ' && result[8]=='0')
37 result[8]=' '; /* fix error in windows ctime */
40 lock_basic_unlock(&ctime_lock);