]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/operational.c
ITS#4310 seems to affect also back-ldbm
[openldap] / servers / slapd / back-ldbm / operational.c
index 51c0fb710f7e85a47a26a9d8bbbabfe16807a017..384437cbf836a1dfd3871095d06b6de964727e7e 100644 (file)
@@ -1,7 +1,17 @@
 /* operational.c - ldbm backend operational attributes function */
-/*
- * Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
 #include "proto-back-ldbm.h"
 
 /*
- * sets the supported operational attributes (if required)
+ * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
+ * if the entry has children or not.
  */
+int
+ldbm_back_hasSubordinates(
+       Operation       *op,
+       Entry           *e,
+       int             *hasSubordinates )
+{
+       if ( has_children( op->o_bd, 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 )
+       SlapReply       *rs )
 {
-       Attribute       **aa = a;
+       Attribute       **ap;
+
+       assert( rs->sr_entry != NULL );
 
-       assert( e );
+       for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
+               /* just count */ ;
 
-       if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
+       if ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
+                       ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
+       {
                int     hs;
 
-               hs = has_children( be, e );
-               *aa = slap_operational_hasSubordinate( hs );
-               if ( *aa != NULL ) {
-                       aa = &(*aa)->a_next;
-               }
+               hs = has_children( op->o_bd, rs->sr_entry );
+               *ap = slap_operational_hasSubordinate( hs );
+               assert( *ap != NULL );
+
+               ap = &(*ap)->a_next;
        }
-       
+
        return 0;
 }