- assert( 0 );
- tag = LBER_ERROR;
- }
- return tag;
-}
-
-static void trim_refs_urls(
- struct berval **refs )
-{
- unsigned i;
-
- if( refs == NULL ) return;
-
- for( i=0; refs[i] != NULL; i++ ) {
- if( refs[i]->bv_len > sizeof("ldap://")-1 &&
- strncasecmp( refs[i]->bv_val, "ldap://",
- sizeof("ldap://")-1 ) == 0 )
- {
- unsigned j;
- for( j=sizeof("ldap://")-1; j<refs[i]->bv_len ; j++ ) {
- if( refs[i]->bv_val[j] == '/' ) {
- refs[i]->bv_val[j] = '\0';
- refs[i]->bv_len = j;
- break;
- }
- }
- }
- }
-}
-
-struct berval **get_entry_referrals(
- Backend *be,
- Connection *conn,
- Operation *op,
- Entry *e )
-{
- Attribute *attr;
- struct berval **refs;
- unsigned i, j;
-
-#ifdef SLAPD_SCHEMA_NOT_COMPAT
- AttributeDescription *ad_ref = slap_schema.si_ad_ref;
-#else
- static const char *ad_ref = "ref";
-#endif
-
- attr = attr_find( e->e_attrs, ad_ref );
-
- if( attr == NULL ) return NULL;
-
- for( i=0; attr->a_vals[i] != NULL; i++ ) {
- /* count references */
- }
-
- if( i < 1 ) return NULL;
-
- refs = ch_malloc( (i + 1) * sizeof(struct berval *));
-
- for( i=0, j=0; attr->a_vals[i] != NULL; i++ ) {
- unsigned k;
- struct berval *ref = ber_bvdup( attr->a_vals[i] );
-
- /* trim the label */
- for( k=0; k<ref->bv_len; k++ ) {
- if( isspace(ref->bv_val[k]) ) {
- ref->bv_val[k] = '\0';
- ref->bv_len = k;
- break;
- }
- }
-
- if( ref->bv_len > 0 ) {
- refs[j++] = ref;
-
- } else {
- ber_bvfree( ref );
- }
- }
-
- refs[j] = NULL;
-
- if( j == 0 ) {
- ber_bvecfree( refs );
- refs = NULL;