X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Foverlays%2Flastmod.c;h=fb5bda9651e851200807c1c32b22b72fb7750464;hb=34f4c2cb97dd6c7851e30298c7e014e170f54665;hp=454239c0bcf63d8f7f01fed73e4247aad03dd1cd;hpb=b4cb3e39c693e091436953ad35a36ce46ad54ef4;p=openldap diff --git a/servers/slapd/overlays/lastmod.c b/servers/slapd/overlays/lastmod.c index 454239c0bc..fb5bda9651 100644 --- a/servers/slapd/overlays/lastmod.c +++ b/servers/slapd/overlays/lastmod.c @@ -1,7 +1,7 @@ /* lastmod.c - returns last modification info */ /* This work is part of OpenLDAP Software . * - * Copyright 2004-2005 The OpenLDAP Foundation. + * Copyright 2004-2006 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -283,7 +283,6 @@ lastmod_op_func( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private; - unsigned i; Modifications *ml; if ( dn_match( &op->o_req_ndn, &lmi->lmi_e->e_nname ) ) { @@ -371,18 +370,17 @@ best_guess( Operation *op, char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; struct berval entryCSN; - slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 ); + entryCSN.bv_val = csnbuf; + entryCSN.bv_len = sizeof( csnbuf ); + slap_get_csn( NULL, &entryCSN, 0 ); ber_dupbv( bv_entryCSN, &entryCSN ); ber_dupbv( bv_nentryCSN, &entryCSN ); } if ( bv_modifyTimestamp ) { - struct tm *tm; -#ifdef HAVE_GMTIME_R - struct tm tm_buf; -#endif char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; + struct berval timestamp; time_t currtime; /* best guess */ @@ -392,18 +390,11 @@ best_guess( Operation *op, /* maybe we better use the time the operation was initiated */ currtime = op->o_time; -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &gmtime_mutex ); - tm = gmtime( &currtime ); -#else /* HAVE_GMTIME_R */ - tm = gmtime_r( &currtime, &tm_buf ); -#endif /* HAVE_GMTIME_R */ - lutil_gentime( tmbuf, sizeof( tmbuf ), tm ); -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); -#endif + timestamp.bv_val = tmbuf; + timestamp.bv_len = sizeof(tmbuf); + slap_timestamp( &currtime, ×tamp ); - ber_str2bv( tmbuf, 0, 1, bv_modifyTimestamp ); + ber_dupbv( bv_modifyTimestamp, ×tamp ); ber_dupbv( bv_nmodifyTimestamp, bv_modifyTimestamp ); } @@ -702,7 +693,6 @@ lastmod_response( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *)op->o_bd->bd_info; lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private; - unsigned int i; /* don't record failed operations */ switch ( rs->sr_err ) { @@ -740,7 +730,6 @@ lastmod_response( Operation *op, SlapReply *rs ) } ldap_pvt_thread_mutex_unlock( &lmi->lmi_entry_mutex ); -process:; (void)lastmod_update( op, rs ); return SLAP_CB_CONTINUE; @@ -781,7 +770,7 @@ lastmod_db_init( return -1; } - code = at_add(at, &err); + code = at_add(at, 0, NULL, &err); if ( code ) { Debug( LDAP_DEBUG_ANY, "lastmod_init: " "%s in attributeType '%s'\n", @@ -824,7 +813,7 @@ lastmod_db_init( return -1; } - code = oc_add(oc, 0, &err); + code = oc_add(oc, 0, NULL, &err); if ( code ) { Debug( LDAP_DEBUG_ANY, "objectClass '%s': %s \"%s\"\n" , @@ -904,14 +893,11 @@ lastmod_db_open( slap_overinst *on = (slap_overinst *) be->bd_info; lastmod_info_t *lmi = (lastmod_info_t *)on->on_bi.bi_private; char buf[ 8192 ]; - struct tm *tms; -#ifdef HAVE_GMTIME_R - struct tm tm_buf; -#endif static char tmbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ]; char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ]; struct berval entryCSN; + struct berval timestamp; if ( !SLAP_LASTMOD( be ) ) { fprintf( stderr, "set \"lastmod on\" to make this overlay effective\n" ); @@ -921,18 +907,13 @@ lastmod_db_open( /* * Start */ -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_lock( &gmtime_mutex ); - tms = gmtime( &starttime ); -#else /* HAVE_GMTIME_R */ - tms = gmtime_r( &starttime, &tm_buf ); -#endif /* HAVE_GMTIME_R */ - lutil_gentime( tmbuf, sizeof(tmbuf), tms ); -#ifndef HAVE_GMTIME_R - ldap_pvt_thread_mutex_unlock( &gmtime_mutex ); -#endif + timestamp.bv_val = tmbuf; + timestamp.bv_len = sizeof(tmbuf); + slap_timestamp( &starttime, ×tamp ); - slap_get_csn( NULL, csnbuf, sizeof(csnbuf), &entryCSN, 0 ); + entryCSN.bv_val = csnbuf; + entryCSN.bv_len = sizeof( csnbuf ); + slap_get_csn( NULL, &entryCSN, 0 ); if ( BER_BVISNULL( &lmi->lmi_rdnvalue ) ) { ber_str2bv( "Lastmod", 0, 1, &lmi->lmi_rdnvalue ); @@ -1014,7 +995,7 @@ lastmod_db_destroy( static slap_overinst lastmod; int -lastmod_init() +lastmod_initialize() { lastmod.on_bi.bi_type = "lastmod"; lastmod.on_bi.bi_db_init = lastmod_db_init; @@ -1039,7 +1020,7 @@ lastmod_init() int init_module( int argc, char *argv[] ) { - return lastmod_init(); + return lastmod_initialize(); } #endif /* SLAPD_OVER_LASTMOD == SLAPD_MOD_DYNAMIC */