--- /dev/null
+/* $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 */
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
--- /dev/null
+/* 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;
+}
+
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
/* 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 ) {
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;