From fdc16c2f948130fa8ab776a199ea3d071ec28547 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Tue, 12 Sep 2000 00:28:08 +0000 Subject: [PATCH] Add initial entry_encode() routine for back-sleepy (behind #if) Need to add entry_decode(). --- servers/slapd/entry.c | 41 ++++++++++++++++++++++++++++++++++++++ servers/slapd/proto-slap.h | 5 ++++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/servers/slapd/entry.c b/servers/slapd/entry.c index c8817c87ef..5b9011e47d 100644 --- a/servers/slapd/entry.c +++ b/servers/slapd/entry.c @@ -223,6 +223,47 @@ entry2str( return( (char *) ebuf ); } +#if SLAPD_SLEEPY +int entry_encode( + Entry *e, + struct berval **bv ) +{ + int rc = -1; + Attribute *a; + BerElement *ber; + + ber = ber_alloc_t( LBER_USE_DER ); + if( ber == NULL ) { + goto done; + } + + rc = ber_printf( ber, "{s{" /*"}}"*/, e->e_dn ); + if( rc < 0 ) { + goto done; + } + + for ( a = e->e_attrs; a != NULL; a = a->a_next ) { + rc = ber_printf( ber, "{O{V}}", + a->a_desc->ad_cname, + a->a_vals ); + if( rc < 0 ) { + goto done; + } + } + + rc = ber_printf( ber, /*"{{"*/ "}}" ); + if( rc < 0 ) { + goto done; + } + + rc = ber_flatten( ber, bv ); + +done: + ber_free( ber, 1 ); + return rc; +} +#endif + void entry_free( Entry *e ) { diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index fbcb5e2510..480ac3e021 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -314,8 +314,11 @@ LDAP_SLAPD_F (int) entry_destroy LDAP_P((void)); LDAP_SLAPD_F (Entry *) str2entry LDAP_P(( char *s )); LDAP_SLAPD_F (char *) entry2str LDAP_P(( Entry *e, int *len )); -LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e )); +LDAP_SLAPD_F (int) entry_decode LDAP_P(( struct berval *bv, Entry **e )); +LDAP_SLAPD_F (int) entry_encode LDAP_P(( Entry *e, struct berval **bv )); + +LDAP_SLAPD_F (void) entry_free LDAP_P(( Entry *e )); LDAP_SLAPD_F (int) entry_cmp LDAP_P(( Entry *a, Entry *b )); LDAP_SLAPD_F (int) entry_dn_cmp LDAP_P(( Entry *a, Entry *b )); LDAP_SLAPD_F (int) entry_id_cmp LDAP_P(( Entry *a, Entry *b )); -- 2.39.5