ava.c 1.05 KB
Newer Older
1
/* $OpenLDAP$ */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
/*
Kurt Zeilenga's avatar
Kurt Zeilenga committed
3
 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
Kurt Zeilenga's avatar
Kurt Zeilenga committed
4
5
 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
 */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
6
7
/* ava.c - routines for dealing with attribute value assertions */

Kurt Zeilenga's avatar
Kurt Zeilenga committed
8
9
#include "portable.h"

Kurt Zeilenga's avatar
Kurt Zeilenga committed
10
#include <stdio.h>
Kurt Zeilenga's avatar
Kurt Zeilenga committed
11
12
13
14

#include <ac/string.h>
#include <ac/socket.h>

Kurt Zeilenga's avatar
Kurt Zeilenga committed
15
16
#include "slap.h"

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifdef SLAPD_SCHEMA_NOT_COMPAT

void
ava_free(
    AttributeAssertion *ava,
    int	freeit
)
{
	ad_free( ava->aa_desc, 1 );
	ber_bvfree( ava->aa_value );
	if ( freeit ) {
		ch_free( (char *) ava );
	}
}

#else

34
35
36
37
38
39
40
41
42
43
44
45
46
void
ava_free(
    Ava	*ava,
    int	freeit
)
{
	ch_free( (char *) ava->ava_type );
	ch_free( (char *) ava->ava_value.bv_val );
	if ( freeit ) {
		ch_free( (char *) ava );
	}
}

Kurt Zeilenga's avatar
Kurt Zeilenga committed
47
48
49
50
51
52
53
54
55
int
get_ava(
    BerElement	*ber,
    Ava		*ava
)
{
	if ( ber_scanf( ber, "{ao}", &ava->ava_type, &ava->ava_value )
	    == LBER_ERROR ) {
		Debug( LDAP_DEBUG_ANY, "  get_ava ber_scanf\n", 0, 0, 0 );
56
		return SLAPD_DISCONNECT;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
57
	}
58

Kurt Zeilenga's avatar
Kurt Zeilenga committed
59
60
61
	attr_normalize( ava->ava_type );
	value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );

62
	return LDAP_SUCCESS;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
63
64
}

65
#endif