operational.c 1.36 KB
Newer Older
1
2
/* operational.c - routines to deal with on-the-fly operational attrs */
/*
Kurt Zeilenga's avatar
Kurt Zeilenga committed
3
 * Copyright 2001-2003 The OpenLDAP Foundation, All Rights Reserved.
4
5
6
7
8
9
10
11
12
13
14
15
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */

#include "portable.h"

#include "slap.h"

/*
 * helpers for on-the-fly operational attribute generation
 */

Attribute *
16
slap_operational_subschemaSubentry( Backend *be )
17
18
19
{
	Attribute	*a;

20
	/* The backend wants to take care of it */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
21
	if ( be && be->be_schemadn.bv_val ) return NULL;
22

23
24
25
	a = ch_malloc( sizeof( Attribute ) );
	a->a_desc = slap_schema.si_ad_subschemaSubentry;

26
	a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
27
	ber_dupbv( a->a_vals, &global_schemadn );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
28
	a->a_vals[1].bv_len = 0;
29
	a->a_vals[1].bv_val = NULL;
30

Kurt Zeilenga's avatar
Kurt Zeilenga committed
31
32
33
34
	a->a_nvals = ch_malloc( 2 * sizeof( struct berval ) );
	ber_dupbv( a->a_nvals, &global_schemandn );
	a->a_nvals[1].bv_len = 0;
	a->a_nvals[1].bv_val = NULL;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
35

36
	a->a_next = NULL;
37
	a->a_flags = 0;
38
39
40
41
42
43
44
45

	return a;
}

Attribute *
slap_operational_hasSubordinate( int hs )
{
	Attribute	*a;
46
	struct berval	val;
47
48

	if ( hs ) {
49
		val = slap_true_bv;
50
51

	} else {
52
		val = slap_false_bv;
53
54
	}

55
56
	a = ch_malloc( sizeof( Attribute ) );
	a->a_desc = slap_schema.si_ad_hasSubordinates;
57
	a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
58

59
	ber_dupbv( &a->a_vals[0], &val );
60
	a->a_vals[1].bv_val = NULL;
61

62
	a->a_nvals = a->a_vals;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
63

64
	a->a_next = NULL;
65
	a->a_flags = 0;
66
67
68
69

	return a;
}