From: Pierangelo Masarati Date: Fri, 14 Aug 2009 15:33:09 +0000 (+0000) Subject: allow to look-ahead entry DN without decoding the whole entry X-Git-Tag: ACLCHECK_0~331 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dc12e58d382600e4e8901f34cbb8f4dd59c33adf;p=openldap allow to look-ahead entry DN without decoding the whole entry --- diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index 65e34fba98..c0e81c54c8 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -820,6 +820,35 @@ int entry_header(EntryHeader *eh) return LDAP_SUCCESS; } +int +entry_decode_dn( EntryHeader *eh, struct berval *dn, struct berval *ndn ) +{ + int i; + unsigned char *ptr = (unsigned char *)eh->bv.bv_val; + + assert( dn != NULL || ndn != NULL ); + + ptr = (unsigned char *)eh->data; + i = entry_getlen(&ptr); + if ( dn != NULL ) { + dn->bv_val = (char *) ptr; + dn->bv_len = i; + } + + if ( ndn != NULL ) { + ptr += i + 1; + i = entry_getlen(&ptr); + ndn->bv_val = (char *) ptr; + ndn->bv_len = i; + } + + Debug( LDAP_DEBUG_TRACE, + "entry_decode_dn: \"%s\"\n", + dn ? dn->bv_val : ndn->bv_val, 0, 0 ); + + return 0; +} + #ifdef SLAP_ZONE_ALLOC int entry_decode(EntryHeader *eh, Entry **e, void *ctx) #else diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index dc41cbd120..48ba6cf4c3 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -976,6 +976,8 @@ LDAP_SLAPD_F (void) entry_partsize LDAP_P(( Entry *e, ber_len_t *len, int *nattrs, int *nvals, int norm )); LDAP_SLAPD_F (int) entry_header LDAP_P(( EntryHeader *eh )); +LDAP_SLAPD_F (int) entry_decode_dn LDAP_P(( + EntryHeader *eh, struct berval *dn, struct berval *ndn )); #ifdef SLAP_ZONE_ALLOC LDAP_SLAPD_F (int) entry_decode LDAP_P(( EntryHeader *eh, Entry **e, void *ctx ));