]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-bdb/attr.c
Sync with HEAD
[openldap] / servers / slapd / back-bdb / attr.c
index 70a20ea9c1caecd877e21117168e1c24327e725f..50182015cce4b6d854d3b11089b3ce8f0d43c505 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "slap.h"
 #include "back-bdb.h"
+#include "lutil.h"
 
 /* for the cache of attribute information (which are indexed, etc.) */
 typedef struct bdb_attrinfo {
@@ -81,7 +82,7 @@ bdb_attr_mask_cr(
                *indexmask = a->ai_indexmask;
                *cr = a->ai_cr;
        } else {
-               *indexmask = NULL;
+               *indexmask = 0;
                *cr = NULL;
        }
 }
@@ -296,6 +297,39 @@ bdb_attr_index_config(
        return LDAP_SUCCESS;
 }
 
+static int
+bdb_attr_index_unparser( void *v1, void *v2 )
+{
+       AttrInfo *ai = v1;
+       BerVarray *bva = v2;
+       struct berval bv;
+       char *ptr;
+
+       slap_index2bvlen( ai->ai_indexmask, &bv );
+       if ( bv.bv_len ) {
+               bv.bv_len += ai->ai_desc->ad_cname.bv_len + 1;
+               ptr = ch_malloc( bv.bv_len+1 );
+               bv.bv_val = lutil_strcopy( ptr, ai->ai_desc->ad_cname.bv_val );
+               *bv.bv_val++ = ' ';
+               slap_index2bv( ai->ai_indexmask, &bv );
+               bv.bv_val = ptr;
+               ber_bvarray_add( bva, &bv );
+       }
+}
+
+static AttributeDescription addef = { NULL, NULL, BER_BVC("default") };
+static AttrInfo aidef = { &addef };
+
+void
+bdb_attr_index_unparse( struct bdb_info *bdb, BerVarray *bva )
+{
+       if ( bdb->bi_defaultmask ) {
+               aidef.ai_indexmask = bdb->bi_defaultmask;
+               bdb_attr_index_unparser( &aidef, bva );
+       }
+       avl_apply( bdb->bi_attrs, bdb_attr_index_unparser, bva, -1, AVL_INORDER );
+}
+
 void
 bdb_attr_index_destroy( Avlnode *tree )
 {