]> git.sur5r.net Git - openldap/blob - servers/slapd/ava.c
Yet another round of SLAPD_SCHEMA_NOT_COMPAT changes, including:
[openldap] / servers / slapd / ava.c
1 /* $OpenLDAP$ */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /* ava.c - routines for dealing with attribute value assertions */
7
8 #include "portable.h"
9
10 #include <stdio.h>
11
12 #include <ac/string.h>
13 #include <ac/socket.h>
14
15 #include "slap.h"
16
17 #ifdef SLAPD_SCHEMA_NOT_COMPAT
18
19 void
20 ava_free(
21     AttributeAssertion *ava,
22     int freeit
23 )
24 {
25         ad_free( ava->aa_desc, 1 );
26         ber_bvfree( ava->aa_value );
27         if ( freeit ) {
28                 ch_free( (char *) ava );
29         }
30 }
31
32 #else
33
34 int
35 get_ava(
36     BerElement  *ber,
37     Ava         *ava
38 )
39 {
40         if ( ber_scanf( ber, "{ao}", &ava->ava_type, &ava->ava_value )
41             == LBER_ERROR ) {
42                 Debug( LDAP_DEBUG_ANY, "  get_ava ber_scanf\n", 0, 0, 0 );
43                 return -1;
44         }
45
46         attr_normalize( ava->ava_type );
47         value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );
48
49         return( LDAP_SUCCESS );
50 }
51
52 void
53 ava_free(
54     Ava *ava,
55     int freeit
56 )
57 {
58         ch_free( (char *) ava->ava_type );
59         ch_free( (char *) ava->ava_value.bv_val );
60         if ( freeit ) {
61                 ch_free( (char *) ava );
62         }
63 }
64
65 #endif