]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/operational.c
4bd743be5ae3b646c1a152a924257bf5da7f82a9
[openldap] / servers / slapd / back-ldbm / operational.c
1 /* operational.c - ldbm backend operational attributes function */
2 /*
3  * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include <stdio.h>
10
11 #include <ac/string.h>
12 #include <ac/socket.h>
13
14 #include "slap.h"
15 #include "back-ldbm.h"
16 #include "proto-back-ldbm.h"
17
18 /*
19  * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
20  * if the entry has children or not.
21  */
22 int
23 ldbm_back_hasSubordinates(
24         Operation       *op,
25         Entry           *e,
26         int             *hasSubordinates )
27 {
28         if ( has_children( op->o_bd, e ) ) {
29                 *hasSubordinates = LDAP_COMPARE_TRUE;
30
31         } else {
32                 *hasSubordinates = LDAP_COMPARE_FALSE;
33         }
34
35         return 0;
36 }
37
38 /*
39  * sets the supported operational attributes (if required)
40  */
41 int
42 ldbm_back_operational(
43         Operation       *op,
44         SlapReply       *rs,
45         int             opattrs,
46         Attribute       **a )
47 {
48         Attribute       **aa = a;
49
50         assert( rs->sr_entry );
51
52         if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) {
53                 int     hs;
54
55                 hs = has_children( op->o_bd, rs->sr_entry );
56                 *aa = slap_operational_hasSubordinate( hs );
57                 if ( *aa != NULL ) {
58                         aa = &(*aa)->a_next;
59                 }
60         }
61         
62         return 0;
63 }
64