From f0a0e9fa324e8febc204590794d93c96a6d3c478 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 18 Aug 2009 08:53:41 +0000 Subject: [PATCH] Revert prev commit, use ldap_pvt_ funcs --- servers/slapd/proto-slap.h | 2 -- servers/slapd/syncrepl.c | 49 ++++---------------------------------- 2 files changed, 5 insertions(+), 46 deletions(-) diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index e14431cdfc..e97fc5e2c0 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -1778,8 +1778,6 @@ LDAP_SLAPD_F (Filter *) str2filter_x LDAP_P(( Operation *op, const char *str )); * syncrepl.c */ -LDAP_SLAPD_F (int) slapd_str2scope LDAP_P(( char *str )); -LDAP_SLAPD_F (struct berval *) slapd_scope2bv LDAP_P(( int scope )); LDAP_SLAPD_F (int) syncrepl_add_glue LDAP_P(( Operation*, Entry* )); LDAP_SLAPD_F (void) syncrepl_diff_entry LDAP_P(( diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 9b8c546b12..b95397f472 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -3808,21 +3808,6 @@ enum { GOT_REQUIRED = (GOT_RID|GOT_PROVIDER|GOT_SEARCHBASE) }; -static struct { - struct berval key; - int val; -} scopes[] = { - { BER_BVC("base"), LDAP_SCOPE_BASE }, - { BER_BVC("one"), LDAP_SCOPE_ONELEVEL }, - { BER_BVC("onelevel"), LDAP_SCOPE_ONELEVEL }, /* OpenLDAP extension */ - { BER_BVC("children"), LDAP_SCOPE_SUBORDINATE }, - { BER_BVC("subord"), LDAP_SCOPE_SUBORDINATE }, - { BER_BVC("subordinate"), LDAP_SCOPE_SUBORDINATE }, - { BER_BVC("sub"), LDAP_SCOPE_SUBTREE }, - { BER_BVC("subtree"), LDAP_SCOPE_SUBTREE }, /* OpenLDAP extension */ - { BER_BVNULL, 0 } -}; - static slap_verbmasks datamodes[] = { { BER_BVC("default"), SYNCDATA_DEFAULT }, { BER_BVC("accesslog"), SYNCDATA_ACCESSLOG }, @@ -3830,29 +3815,6 @@ static slap_verbmasks datamodes[] = { { BER_BVNULL, 0 } }; -int -slapd_str2scope( char *str ) -{ - int i; - for ( i = 0; !BER_BVISNULL(&scopes[i].key); i++ ) { - if (!strcasecmp( str, scopes[i].key.bv_val ) ) { - return scopes[i].val; - } - } - return -1; -} - -struct berval * -slapd_scope2bv( int scope ) -{ - int i; - for (i=0; !BER_BVISNULL(&scopes[i].key);i++) { - if ( scope == scopes[i].val ) - return &scopes[i].key; - } - return NULL; -} - static int parse_syncrepl_retry( ConfigArgs *c, @@ -4063,7 +4025,7 @@ parse_syncrepl_line( { int j; val = c->argv[ i ] + STRLENOF( SCOPESTR "=" ); - j = slapd_str2scope( val ); + j = ldap_pvt_str2scope( val ); if ( j < 0 ) { snprintf( c->cr_msg, sizeof( c->cr_msg ), "Error: parse_syncrepl_line: " @@ -4475,7 +4437,7 @@ add_syncrepl( static void syncrepl_unparse( syncinfo_t *si, struct berval *bv ) { - struct berval bc, uri, *bs; + struct berval bc, uri, bs; char buf[BUFSIZ*2], *ptr; ber_len_t len; int i; @@ -4529,11 +4491,10 @@ syncrepl_unparse( syncinfo_t *si, struct berval *bv ) ptr = lutil_strcopy( ptr, si->si_logbase.bv_val ); *ptr++ = '"'; } - bs = slapd_scope2bv( si->si_scope ); - if ( bs ) { - if ( WHATSLEFT <= STRLENOF( " " SCOPESTR "=" ) + bs->bv_len ) return; + if ( ldap_pvt_scope2bv( si->si_scope, &bs ) == LDAP_SUCCESS ) { + if ( WHATSLEFT <= STRLENOF( " " SCOPESTR "=" ) + bs.bv_len ) return; ptr = lutil_strcopy( ptr, " " SCOPESTR "=" ); - ptr = lutil_strcopy( ptr, bs->bv_val ); + ptr = lutil_strcopy( ptr, bs.bv_val ); } if ( si->si_attrsonly ) { if ( WHATSLEFT <= STRLENOF( " " ATTRSONLYSTR "=\"" "\"" ) ) return; -- 2.39.5