ava.c 1.04 KB
Newer Older
1
/* $OpenLDAP$ */
Kurt Zeilenga's avatar
Kurt Zeilenga committed
2
3
4
5
/*
 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
 * 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

Kurt Zeilenga's avatar
Kurt Zeilenga committed
34
35
36
37
38
39
40
41
42
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 );
43
		return -1;
Kurt Zeilenga's avatar
Kurt Zeilenga committed
44
	}
45

Kurt Zeilenga's avatar
Kurt Zeilenga committed
46
47
48
	attr_normalize( ava->ava_type );
	value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );

49
	return( LDAP_SUCCESS );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
50
51
52
53
54
55
56
57
}

void
ava_free(
    Ava	*ava,
    int	freeit
)
{
58
59
	ch_free( (char *) ava->ava_type );
	ch_free( (char *) ava->ava_value.bv_val );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
60
	if ( freeit ) {
61
		ch_free( (char *) ava );
Kurt Zeilenga's avatar
Kurt Zeilenga committed
62
63
64
	}
}

65
#endif