]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/operational.c
use slab memory for proxyauthz
[openldap] / servers / slapd / back-ldbm / operational.c
index 81fe0efb1edbda15c953eb45a54091227bc7e2c7..384437cbf836a1dfd3871095d06b6de964727e7e 100644 (file)
@@ -1,7 +1,17 @@
 /* operational.c - ldbm backend operational attributes function */
-/*
- * Copyright 1998-2001 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_operational(
-       BackendDB       *be,
-       Connection      *conn, 
+ldbm_back_hasSubordinates(
        Operation       *op,
        Entry           *e,
-       char            **attrs,
-       int             opattrs,
-       Attribute       **a )
+       int             *hasSubordinates )
 {
-       Attribute       **aa = a;
+       if ( has_children( op->o_bd, e ) ) {
+               *hasSubordinates = LDAP_COMPARE_TRUE;
 
-       assert( e );
+       } else {
+               *hasSubordinates = LDAP_COMPARE_FALSE;
+       }
 
-       if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, attrs ) ) {
-               int     hs;
+       return 0;
+}
 
-               hs = has_children( be, e );
+/*
+ * sets the supported operational attributes (if required)
+ */
+int
+ldbm_back_operational(
+       Operation       *op,
+       SlapReply       *rs )
+{
+       Attribute       **ap;
 
-               *aa = ch_malloc( sizeof( Attribute ) );
-               (*aa)->a_desc = slap_schema.si_ad_hasSubordinates;
+       assert( rs->sr_entry != NULL );
 
-               (*aa)->a_vals = ch_malloc( 2 * sizeof( struct berval * ) );
-               (*aa)->a_vals[0] = ber_bvstrdup( hs ? "TRUE" : "FALSE" );
-               (*aa)->a_vals[1] = NULL;
+       for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next )
+               /* just count */ ;
 
-               (*aa)->a_next = NULL;
-               aa = &(*aa)->a_next;
+       if ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
+                       ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) )
+       {
+               int     hs;
+
+               hs = has_children( op->o_bd, rs->sr_entry );
+               *ap = slap_operational_hasSubordinate( hs );
+               assert( *ap != NULL );
+
+               ap = &(*ap)->a_next;
        }
-       
+
        return 0;
 }