]> git.sur5r.net Git - openldap/blob - servers/slapd/operational.c
fix possible uninitialized use of nmods
[openldap] / servers / slapd / operational.c
1 /* operational.c - routines to deal with on-the-fly operational attrs */
2 /*
3  * Copyright 2001-2002 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6
7 #include "portable.h"
8
9 #include "slap.h"
10
11 /*
12  * helpers for on-the-fly operational attribute generation
13  */
14
15 Attribute *
16 slap_operational_subschemaSubentry( Backend *be )
17 {
18         Attribute       *a;
19
20         /* The backend wants to take care of it */
21         if ( be && be->be_schemadn.bv_val )
22                 return NULL;
23
24         a = ch_malloc( sizeof( Attribute ) );
25         a->a_desc = slap_schema.si_ad_subschemaSubentry;
26
27         a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
28         ber_dupbv( a->a_vals, &global_schemadn );
29         a->a_vals[1].bv_val = NULL;
30
31         a->a_next = NULL;
32         a->a_flags = 0;
33
34         return a;
35 }
36
37 Attribute *
38 slap_operational_hasSubordinate( int hs )
39 {
40         Attribute       *a;
41         char            *val;
42         ber_len_t       len;
43
44         if ( hs ) {
45                 val = "TRUE";
46                 len = sizeof( "TRUE" ) - 1;
47
48         } else {
49                 val = "FALSE";
50                 len = sizeof( "FALSE" ) - 1;
51
52         }
53
54         a = ch_malloc( sizeof( Attribute ) );
55         a->a_desc = slap_schema.si_ad_hasSubordinates;
56         a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
57
58         ber_str2bv( val, len, 1, a->a_vals );
59         a->a_vals[1].bv_val = NULL;
60
61         a->a_next = NULL;
62         a->a_flags = 0;
63
64         return a;
65 }
66