]> git.sur5r.net Git - openldap/commitdiff
HasSubordinate stuff
authorKurt Zeilenga <kurt@openldap.org>
Tue, 29 Oct 2002 02:18:10 +0000 (02:18 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 29 Oct 2002 02:18:10 +0000 (02:18 +0000)
servers/slapd/back-ldbm/external.h [new file with mode: 0644]
servers/slapd/back-ldbm/init.c
servers/slapd/back-ldbm/operational.c [new file with mode: 0644]
servers/slapd/back-ldbm/search.c

diff --git a/servers/slapd/back-ldbm/external.h b/servers/slapd/back-ldbm/external.h
new file mode 100644 (file)
index 0000000..93b40b1
--- /dev/null
@@ -0,0 +1,65 @@
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#ifndef _LDBM_EXTERNAL_H
+#define _LDBM_EXTERNAL_H
+
+LDAP_BEGIN_DECL
+
+extern BI_init ldbm_back_initialize;
+extern BI_open ldbm_back_open;
+extern BI_close        ldbm_back_close;
+extern BI_destroy      ldbm_back_destroy;
+
+extern BI_db_init      ldbm_back_db_init;
+extern BI_db_open      ldbm_back_db_open;
+extern BI_db_close     ldbm_back_db_close;
+extern BI_db_destroy   ldbm_back_db_destroy;
+
+extern BI_db_config    ldbm_back_db_config;
+
+extern BI_op_extended  ldbm_back_extended;
+
+extern BI_op_bind      ldbm_back_bind;
+
+extern BI_op_search    ldbm_back_search;
+
+extern BI_op_compare   ldbm_back_compare;
+
+extern BI_op_modify    ldbm_back_modify;
+
+extern BI_op_modrdn    ldbm_back_modrdn;
+
+extern BI_op_add       ldbm_back_add;
+
+extern BI_op_delete    ldbm_back_delete;
+
+extern BI_acl_group    ldbm_back_group;
+
+extern BI_acl_attribute        ldbm_back_attribute;
+
+extern BI_operational  ldbm_back_operational;
+
+#ifdef SLAP_X_FILTER_HASSUBORDINATES
+extern BI_has_subordinates     ldbm_back_hasSubordinates;
+#endif /* SLAP_X_FILTER_HASSUBORDINATES */
+
+/* hooks for slap tools */
+extern BI_tool_entry_open      ldbm_tool_entry_open;
+extern BI_tool_entry_close     ldbm_tool_entry_close;
+extern BI_tool_entry_first     ldbm_tool_entry_first;
+extern BI_tool_entry_next      ldbm_tool_entry_next;
+extern BI_tool_entry_get       ldbm_tool_entry_get;
+extern BI_tool_entry_put       ldbm_tool_entry_put;
+
+extern BI_tool_entry_reindex   ldbm_tool_entry_reindex;
+extern BI_tool_sync    ldbm_tool_sync;
+
+extern BI_chk_referrals        ldbm_back_referrals;
+
+LDAP_END_DECL
+
+#endif /* _LDBM_EXTERNAL_H */
index be55fac73c7de7d47d77186e5d3188493fb6bab5..327b0b79a99b1612b29fcc178405d6d200c0de87 100644 (file)
@@ -71,6 +71,9 @@ ldbm_back_initialize(
        bi->bi_acl_attribute = ldbm_back_attribute;
        bi->bi_chk_referrals = ldbm_back_referrals;
        bi->bi_operational = ldbm_back_operational;
+#ifdef SLAP_X_FILTER_HASSUBORDINATES
+       bi->bi_has_subordinates = ldbm_back_hasSubordinates;
+#endif /* SLAP_X_FILTER_HASSUBORDINATES */
 
        /*
         * hooks for slap tools
diff --git a/servers/slapd/back-ldbm/operational.c b/servers/slapd/back-ldbm/operational.c
new file mode 100644 (file)
index 0000000..bc68116
--- /dev/null
@@ -0,0 +1,69 @@
+/* operational.c - ldbm backend operational attributes function */
+/*
+ * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
+#include "portable.h"
+
+#include <stdio.h>
+
+#include <ac/string.h>
+#include <ac/socket.h>
+
+#include "slap.h"
+#include "back-ldbm.h"
+#include "proto-back-ldbm.h"
+
+/*
+ * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
+ * if the entry has children or not.
+ */
+int
+ldbm_back_hasSubordinates(
+       BackendDB       *be,
+       Connection      *conn, 
+       Operation       *op,
+       Entry           *e,
+       int             *hasSubordinates )
+{
+       if ( has_children( be, e ) ) {
+               *hasSubordinates = LDAP_COMPARE_TRUE;
+
+       } else {
+               *hasSubordinates = LDAP_COMPARE_FALSE;
+       }
+
+       return 0;
+}
+
+/*
+ * sets the supported operational attributes (if required)
+ */
+int
+ldbm_back_operational(
+       BackendDB       *be,
+       Connection      *conn, 
+       Operation       *op,
+       Entry           *e,
+       AttributeName           *attrs,
+       int             opattrs,
+       Attribute       **a )
+{
+       Attribute       **aa = a;
+
+       assert( e );
+
+       if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
+               int     hs;
+
+               hs = has_children( be, e );
+               *aa = slap_operational_hasSubordinate( hs );
+               if ( *aa != NULL ) {
+                       aa = &(*aa)->a_next;
+               }
+       }
+       
+       return 0;
+}
+
index eac5f831e9cc125a7bba4b4bb83afe27462ce404..1d41140078e5d8ea107e6be99b22680834de4890 100644 (file)
@@ -57,10 +57,6 @@ ldbm_back_search(
        struct slap_limits_set *limit = NULL;
        int isroot = 0;
                
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-       int             filter_hasSubordinates = 0;
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
-
 #ifdef NEW_LOGGING
        LDAP_LOG( BACK_LDBM, ENTRY, "ldbm_back_search: enter\n", 0, 0, 0 );
 #else
@@ -292,22 +288,11 @@ searchit:
        /* compute it anyway; root does not use it */
        stoptime = op->o_time + tlimit;
 
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-       /*
-        * is hasSubordinates used in the filter ?
-        * FIXME: we may compute this directly when parsing the filter
-        */
-       filter_hasSubordinates = filter_has_subordinates( filter );
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
-
        for ( id = idl_firstid( candidates, &cursor ); id != NOID;
            id = idl_nextid( candidates, &cursor ) )
        {
                int scopeok = 0;
                int result = 0;
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-               Attribute       *hasSubordinates = NULL;
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
 
                /* check for abandon */
                if ( op->o_abandon ) {
@@ -436,43 +421,9 @@ searchit:
                        goto loop_continue;
                }
 
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-               /*
-                * if hasSubordinates is used in the filter,
-                * append it to the entry's attributes
-                */
-               if ( filter_hasSubordinates ) {
-                       int     hs;
-
-                       hs = has_children( be, e );
-                       hasSubordinates = slap_operational_hasSubordinate( hs );
-                       if ( hasSubordinates == NULL ) {
-                               goto loop_continue;
-                       }
-
-                       hasSubordinates->a_next = e->e_attrs;
-                       e->e_attrs = hasSubordinates;
-               }
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
-
                /* if it matches the filter and scope, send it */
                result = test_filter( be, conn, op, e, filter );
 
-#ifdef SLAP_X_FILTER_HASSUBORDINATES
-               if ( hasSubordinates ) {
-                       /*
-                        * FIXME: this is fairly inefficient, because 
-                        * if hasSubordinates is among the required
-                        * attrs, it will be added again later;
-                        * maybe we should leave it and check
-                        * check later if it's already present,
-                        * if required
-                        */
-                       e->e_attrs = e->e_attrs->a_next;
-                       attr_free( hasSubordinates );
-               }
-#endif /* SLAP_X_FILTER_HASSUBORDINATES */
-
                if ( result == LDAP_COMPARE_TRUE ) {
                        struct berval   dn;