]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/backglue.c
More system schema checks
[openldap] / servers / slapd / backglue.c
index e331ca85ec2d64025f26e20bbb7077ab07cefd55..11eca56d1328a55f4d3ecdb3e0a61b2e1694ba29 100644 (file)
@@ -1,7 +1,7 @@
 /* backglue.c - backend glue routines */
 /* $OpenLDAP$ */
 /*
- * Copyright 2001 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 2001-2002 The OpenLDAP Foundation, All Rights Reserved.
  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
  */
 
@@ -169,7 +169,7 @@ typedef struct glue_state {
        int matchlen;
        char *matched;
        int nrefs;
-       struct berval **refs;
+       BVarray refs;
 } glue_state;
 
 static void
@@ -181,7 +181,7 @@ glue_back_response (
        ber_int_t err,
        const char *matched,
        const char *text,
-       struct berval **ref,
+       BVarray ref,
        const char *resoid,
        struct berval *resdata,
        struct berval *sasldata,
@@ -208,21 +208,21 @@ glue_back_response (
        }
        if (ref) {
                int i, j, k;
-               struct berval **new;
+               BVarray new;
 
-               for (i=0; ref[i]; i++);
+               for (i=0; ref[i].bv_val; i++);
 
                j = gs->nrefs;
                if (!j) {
-                       new = ch_malloc ((i+1)*sizeof(struct berval *));
+                       new = ch_malloc ((i+1)*sizeof(struct berval));
                } else {
                        new = ch_realloc(gs->refs,
-                               (j+i+1)*sizeof(struct berval *));
+                               (j+i+1)*sizeof(struct berval));
                }
                for (k=0; k<i; j++,k++) {
-                       new[j] = ber_bvdup(ref[k]);
+                       ber_dupbv( &new[j], &ref[k] );
                }
-               new[j] = NULL;
+               new[j].bv_val = NULL;
                gs->nrefs = j;
                gs->refs = new;
        }
@@ -235,7 +235,7 @@ glue_back_sresult (
        ber_int_t err,
        const char *matched,
        const char *text,
-       struct berval **refs,
+       BVarray refs,
        LDAPControl **ctrls,
        int nentries
 )
@@ -259,8 +259,8 @@ glue_back_search (
        int slimit,
        int tlimit,
        Filter *filter,
-       const char *filterstr,
-       struct berval **attrs,
+       struct berval *filterstr,
+       AttributeName *attrs,
        int attrsonly
 )
 {
@@ -360,7 +360,7 @@ done:
        if (gs.matched)
                free (gs.matched);
        if (gs.refs)
-               ber_bvecfree(gs.refs);
+               bvarray_free(gs.refs);
        return rc;
 }
 
@@ -548,8 +548,8 @@ glue_back_group (
        Connection *conn,
        Operation *op,
        Entry *target,
-       const char *ndn,
-       const char *ondn,
+       struct berval *ndn,
+       struct berval *ondn,
        ObjectClass *oc,
        AttributeDescription * ad
 )
@@ -557,7 +557,7 @@ glue_back_group (
        BackendDB *be;
        int rc;
 
-       be = glue_back_select (b0, ndn);
+       be = glue_back_select (b0, ndn->bv_val);
 
        if (be && be->be_group) {
                rc = be->be_group (be, conn, op, target, ndn, ondn, oc, ad);
@@ -573,15 +573,15 @@ glue_back_attribute (
        Connection *conn,
        Operation *op,
        Entry *target,
-       const char *ndn,
+       struct berval *ndn,
        AttributeDescription *ad,
-       struct berval ***vals
+       BVarray *vals
 )
 {
        BackendDB *be;
        int rc;
 
-       be = glue_back_select (b0, ndn);
+       be = glue_back_select (b0, ndn->bv_val);
 
        if (be && be->be_attribute) {
                rc = be->be_attribute (be, conn, op, target, ndn, ad, vals);
@@ -766,7 +766,7 @@ glue_tool_sync (
        int i;
 
        /* just sync everyone */
-       for (i = 0; b0->be_nsuffix[i]; i++)
+       for (i = 0; i<gi->nodes; i++)
                if (gi->n[i].be->be_sync)
                        gi->n[i].be->be_sync (gi->n[i].be);
        return 0;
@@ -776,7 +776,7 @@ int
 glue_sub_init( )
 {
        int i, j;
-       int cont = num_subs;
+       int cont = num_subordinates;
        BackendDB *b1, *be;
        BackendInfo *bi;
        glueinfo *gi;
@@ -785,24 +785,27 @@ glue_sub_init( )
         * backends and connect them to their superior.
         */
        for (i = nBackendDB - 1, b1=&backendDB[i]; cont && i>=0; b1--,i--) {
-               if (b1->be_glueflags & SLAP_GLUE_SUBORDINATE) {
+               if (b1->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE) {
                        /* The last database cannot be a subordinate of noone */
-                       if (i == nBackendDB - 1)
-                               b1->be_glueflags ^= SLAP_GLUE_SUBORDINATE;
+                       if (i == nBackendDB - 1) {
+                               b1->be_flags ^= SLAP_BFLAG_GLUE_SUBORDINATE;
+                       }
                        continue;
                }
                gi = NULL;
                for (j = i-1, be=&backendDB[j]; j>=0; be--,j--) {
-                       if (!(be->be_glueflags & SLAP_GLUE_SUBORDINATE))
+                       if (!(be->be_flags & SLAP_BFLAG_GLUE_SUBORDINATE)) {
                                continue;
+                       }
                        /* We will only link it once */
-                       if (be->be_glueflags & SLAP_GLUE_LINKED)
+                       if (be->be_flags & SLAP_BFLAG_GLUE_LINKED) {
                                continue;
-                       if (!dnIsSuffix(be->be_nsuffix[0],
-                               b1->be_nsuffix[0]))
+                       }
+                       if (!dnIsSuffix(be->be_nsuffix[0], b1->be_nsuffix[0])) {
                                continue;
+                       }
                        cont--;
-                       be->be_glueflags |= SLAP_GLUE_LINKED;
+                       be->be_flags |= SLAP_BFLAG_GLUE_LINKED;
                        if (gi == NULL) {
                                /* We create a copy of the superior's be
                                 * structure, pointing to all of its original
@@ -811,9 +814,10 @@ glue_sub_init( )
                                 * is used whenever we have operations to pass
                                 * down to the real database.
                                 */
-                               b1->be_glueflags |= SLAP_GLUE_INSTANCE;
+                               b1->be_flags |= SLAP_BFLAG_GLUE_INSTANCE;
                                gi = (glueinfo *)ch_malloc(sizeof(glueinfo));
-                               gi->be = (BackendDB *)ch_malloc(sizeof(BackendDB) + sizeof(BackendInfo));
+                               gi->be = (BackendDB *)ch_malloc(
+                                       sizeof(BackendDB) + sizeof(BackendInfo));
                                bi = (BackendInfo *)(gi->be+1);
                                *gi->be = *b1;
                                gi->nodes = 0;