]> git.sur5r.net Git - openldap/blob - servers/slapd/ava.c
Add LDAPsubentry (without OID).
[openldap] / servers / slapd / ava.c
1 /*
2  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5 /* ava.c - routines for dealing with attribute value assertions */
6
7 #include "portable.h"
8
9 #include <stdio.h>
10
11 #include <ac/string.h>
12 #include <ac/socket.h>
13
14 #include "slap.h"
15
16 int
17 get_ava(
18     BerElement  *ber,
19     Ava         *ava
20 )
21 {
22         if ( ber_scanf( ber, "{ao}", &ava->ava_type, &ava->ava_value )
23             == LBER_ERROR ) {
24                 Debug( LDAP_DEBUG_ANY, "  get_ava ber_scanf\n", 0, 0, 0 );
25                 return( -1 );
26         }
27         attr_normalize( ava->ava_type );
28         value_normalize( ava->ava_value.bv_val, attr_syntax( ava->ava_type ) );
29
30         return( LDAP_SUCCESS );
31 }
32
33 void
34 ava_free(
35     Ava *ava,
36     int freeit
37 )
38 {
39         free( (char *) ava->ava_type );
40         free( (char *) ava->ava_value.bv_val );
41         if ( freeit ) {
42                 free( (char *) ava );
43         }
44 }
45