char ctmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
struct tm *mtm;
char mtmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+#ifdef HAVE_GMTIME_R
+ struct tm tm_buf;
+#endif /* HAVE_GMTIME_R */
assert( c != NULL );
assert( ep != NULL );
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#endif
#ifdef HACK_LOCAL_TIME
+# ifdef HAVE_LOCALTIME_R
+ ctm = localtime_r( &c->c_starttime, &tm_buf );
+ lutil_localtime( ctmbuf, sizeof( ctmbuf ), ctm, -timezone );
+ mtm = localtime_r( &c->c_activitytime, &tm_buf );
+ lutil_localtime( mtmbuf, sizeof( mtmbuf ), mtm, -timezone );
+# else
ctm = localtime( &c->c_starttime );
lutil_localtime( ctmbuf, sizeof( ctmbuf ), ctm, -timezone );
mtm = localtime( &c->c_activitytime );
lutil_localtime( mtmbuf, sizeof( mtmbuf ), mtm, -timezone );
+# endif /* HAVE_LOCALTIME_R */
#else /* !HACK_LOCAL_TIME */
+# ifdef HAVE_GMTIME_R
+ ctm = gmtime_r( &c->c_starttime, &tm_buf );
+ lutil_gentime( ctmbuf, sizeof( ctmbuf ), ctm );
+ mtm = gmtime_r( &c->c_activitytime, &tm_buf );
+ lutil_gentime( mtmbuf, sizeof( mtmbuf ), mtm );
+# else
ctm = gmtime( &c->c_starttime );
lutil_gentime( ctmbuf, sizeof( ctmbuf ), ctm );
mtm = gmtime( &c->c_activitytime );
lutil_gentime( mtmbuf, sizeof( mtmbuf ), mtm );
+# endif /* HAVE_GMTIME_R */
#endif /* !HACK_LOCAL_TIME */
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
snprintf( buf, sizeof( buf ),
"dn: cn=" CONN_CN_PREFIX " %ld,%s\n"
return( -1 );
}
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
-
+#endif
+
+#ifdef HAVE_GMTIME_R
+ ltm = gmtime_r( &c->c_starttime, &tm_buf );
+#else
ltm = gmtime( &c->c_starttime );
+#endif
lutil_gentime( buf2, sizeof( buf2 ), ltm );
-
+
+#ifdef HAVE_GMTIME_R
+ ltm = gmtime_r( &c->c_activitytime, &tm_buf );
+#else
ltm = gmtime( &c->c_activitytime );
+#endif
lutil_gentime( buf3, sizeof( buf3 ), ltm );
-
+
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif /* HAVE_GMTIME_R */
/* monitored info */
sprintf( buf,
};
struct tm *tms;
+#ifdef HAVE_GMTIME_R
+ struct tm tm_buf;
+#endif
static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
/*
* Start
*/
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#endif
#ifdef HACK_LOCAL_TIME
+# ifdef HAVE_LOCALTIME_R
+ tms = localtime_r( &starttime, &tm_buf );
+# else
tms = localtime( &starttime );
+# endif /* HAVE_LOCALTIME_R */
lutil_localtime( tmbuf, sizeof(tmbuf), tms, -timezone );
#else /* !HACK_LOCAL_TIME */
+# ifdef HAVE_GMTIME_R
+ tms = gmtime_r( &starttime, &tm_buf );
+# else
tms = gmtime( &starttime );
+# endif /* HAVE_GMTIME_R */
lutil_gentime( tmbuf, sizeof(tmbuf), tms );
#endif /* !HACK_LOCAL_TIME */
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
mi->mi_startTime.bv_val = tmbuf;
mi->mi_startTime.bv_len = strlen( tmbuf );
if ( strncmp( e->e_nname.bv_val, "cn=current",
sizeof("cn=current") - 1 ) == 0 ) {
struct tm *tm;
+#ifdef HAVE_GMTIME_R
+ struct tm tm_buf;
+#endif
char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
Attribute *a;
ber_len_t len;
currtime = slap_get_time();
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_lock( &gmtime_mutex );
+#endif
#ifdef HACK_LOCAL_TIME
+# ifdef HAVE_LOCALTIME_R
+ tm = localtime_r( &currtime, &tm_buf );
+# else
tm = localtime( &currtime );
+# endif /* HAVE_LOCALTIME_R */
lutil_localtime( tmbuf, sizeof( tmbuf ), tm, -timezone );
#else /* !HACK_LOCAL_TIME */
+# ifdef HAVE_GMTIME_R
+ tm = gmtime_r( &currtime, &tm_buf );
+# else
tm = gmtime( &currtime );
+# endif /* HAVE_GMTIME_R */
lutil_gentime( tmbuf, sizeof( tmbuf ), tm );
#endif /* !HACK_LOCAL_TIME */
+#ifndef HAVE_GMTIME_R
ldap_pvt_thread_mutex_unlock( &gmtime_mutex );
+#endif
len = strlen( tmbuf );