]> git.sur5r.net Git - openldap/blob - servers/slapd/ava.c
5bc0ec3d6b764d8d4449070b11b6f86e24f4336c
[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 int
18 get_ava(
19     BerElement  *ber,
20     Ava         *ava
21 )
22 {
23         if ( ber_scanf( ber, "{ao}", &ava->ava_type, &ava->ava_value )
24             == LBER_ERROR ) {
25                 Debug( LDAP_DEBUG_ANY, "  get_ava ber_scanf\n", 0, 0, 0 );
26                 return( -1 );
27         }
28         attr_normalize( ava->ava_type );
29 #ifdef SLAPD_SCHEMA_COMPAT
30         value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );
31 #endif
32
33         return( LDAP_SUCCESS );
34 }
35
36 void
37 ava_free(
38     Ava *ava,
39     int freeit
40 )
41 {
42         free( (char *) ava->ava_type );
43         free( (char *) ava->ava_value.bv_val );
44         if ( freeit ) {
45                 free( (char *) ava );
46         }
47 }
48