]> git.sur5r.net Git - openldap/blob - servers/slapd/back-ldbm/operational.c
Happy new year
[openldap] / servers / slapd / back-ldbm / operational.c
1 /* operational.c - ldbm backend operational attributes function */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 1998-2004 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20
21 #include <ac/string.h>
22 #include <ac/socket.h>
23
24 #include "slap.h"
25 #include "back-ldbm.h"
26 #include "proto-back-ldbm.h"
27
28 /*
29  * sets *hasSubordinates to LDAP_COMPARE_TRUE/LDAP_COMPARE_FALSE
30  * if the entry has children or not.
31  */
32 int
33 ldbm_back_hasSubordinates(
34         Operation       *op,
35         Entry           *e,
36         int             *hasSubordinates )
37 {
38         if ( has_children( op->o_bd, e ) ) {
39                 *hasSubordinates = LDAP_COMPARE_TRUE;
40
41         } else {
42                 *hasSubordinates = LDAP_COMPARE_FALSE;
43         }
44
45         return 0;
46 }
47
48 /*
49  * sets the supported operational attributes (if required)
50  */
51 int
52 ldbm_back_operational(
53         Operation       *op,
54         SlapReply       *rs,
55         int             opattrs,
56         Attribute       **a )
57 {
58         Attribute       **aa = a;
59
60         assert( rs->sr_entry );
61
62         if ( opattrs || ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) {
63                 int     hs;
64
65                 hs = has_children( op->o_bd, rs->sr_entry );
66                 *aa = slap_operational_hasSubordinate( hs );
67                 if ( *aa != NULL ) {
68                         aa = &(*aa)->a_next;
69                 }
70         }
71         
72         return 0;
73 }
74