operational.c 2.2 KB
Newer Older
1
/* operational.c - routines to deal with on-the-fly operational attrs */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
3
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
 *
Kurt Zeilenga's avatar
Kurt Zeilenga committed
4
 * Copyright 2001-2004 The OpenLDAP Foundation.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
5
6
7
8
9
10
11
12
13
 * 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>.
14
15
16
17
18
19
20
21
22
23
24
 */

#include "portable.h"

#include "slap.h"

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

Attribute *
25
slap_operational_subschemaSubentry( Backend *be )
26
27
28
{
	Attribute	*a;

29
	/* The backend wants to take care of it */
30
	if ( be && be!= frontendDB && be->be_schemadn.bv_val ) return NULL;
31

32
33
34
	a = ch_malloc( sizeof( Attribute ) );
	a->a_desc = slap_schema.si_ad_subschemaSubentry;

35
	a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
36
	ber_dupbv( a->a_vals, &frontendDB->be_schemadn );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
37
	a->a_vals[1].bv_len = 0;
38
	a->a_vals[1].bv_val = NULL;
39

Kurt Zeilenga's avatar
Kurt Zeilenga committed
40
	a->a_nvals = ch_malloc( 2 * sizeof( struct berval ) );
41
	ber_dupbv( a->a_nvals, &frontendDB->be_schemandn );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
42
43
	a->a_nvals[1].bv_len = 0;
	a->a_nvals[1].bv_val = NULL;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
44

45
	a->a_next = NULL;
46
	a->a_flags = 0;
47
48
49
50

	return a;
}

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Attribute *
slap_operational_entryDN( Entry *e )
{
	Attribute	*a;

	a = ch_malloc( sizeof( Attribute ) );
	a->a_desc = slap_schema.si_ad_entryDN;

	a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
	ber_dupbv( a->a_vals, &e->e_name );
	a->a_vals[1].bv_len = 0;
	a->a_vals[1].bv_val = NULL;

	a->a_nvals = ch_malloc( 2 * sizeof( struct berval ) );
	ber_dupbv( a->a_nvals, &e->e_nname );
	a->a_nvals[1].bv_len = 0;
	a->a_nvals[1].bv_val = NULL;

	a->a_next = NULL;
	a->a_flags = 0;

	return a;
}

75
76
77
78
Attribute *
slap_operational_hasSubordinate( int hs )
{
	Attribute	*a;
79
	struct berval	val;
80

81
	val = hs ? slap_true_bv : slap_false_bv;
82

83
84
	a = ch_malloc( sizeof( Attribute ) );
	a->a_desc = slap_schema.si_ad_hasSubordinates;
85
	a->a_vals = ch_malloc( 2 * sizeof( struct berval ) );
86

87
	ber_dupbv( &a->a_vals[0], &val );
88
	a->a_vals[1].bv_val = NULL;
89

90
	a->a_nvals = a->a_vals;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
91

92
	a->a_next = NULL;
93
	a->a_flags = 0;
94
95
96
97

	return a;
}