3 * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
6 /* mra.c - routines for dealing with extensible matching rule assertions */
12 #include <ac/string.h>
13 #include <ac/socket.h>
20 MatchingRuleAssertion *mra,
24 ad_free( mra->ma_desc, 1 );
25 ch_free( (char *) mra->ma_rule );
26 ber_bvfree( mra->ma_value );
28 ch_free( (char *) mra );
35 MatchingRuleAssertion **mra,
40 struct berval type, value, *nvalue;
41 MatchingRuleAssertion *ma;
43 ma = ch_malloc( sizeof( MatchingRuleAssertion ) );
49 rc = ber_scanf( ber, "{t", &tag );
51 if( rc == LBER_ERROR ) {
52 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
53 *text = "Error parsing matching rule assertion";
54 return SLAPD_DISCONNECT;
57 if ( tag == LDAP_FILTER_EXT_OID ) {
58 rc = ber_scanf( ber, "a", &ma->ma_rule );
59 if ( rc == LBER_ERROR ) {
60 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for mr\n", 0, 0, 0 );
61 *text = "Error parsing matching rule in matching rule assertion";
62 return SLAPD_DISCONNECT;
65 rc = ber_scanf( ber, "t", &tag );
67 if( rc == LBER_ERROR ) {
68 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
69 *text = "Error parsing matching rule assertion";
70 return SLAPD_DISCONNECT;
74 if ( tag == LDAP_FILTER_EXT_TYPE ) {
75 rc = ber_scanf( ber, "o", &type );
76 if ( rc == LBER_ERROR ) {
77 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf for ad\n", 0, 0, 0 );
78 *text = "Error parsing attribute description in matching rule assertion";
79 return SLAPD_DISCONNECT;
82 rc = slap_bv2ad( &type, &ma->ma_desc, text );
83 ch_free( type.bv_val );
85 if( rc != LDAP_SUCCESS ) {
86 ch_free( value.bv_val );
91 rc = ber_scanf( ber, "t", &tag );
93 if( rc == LBER_ERROR ) {
94 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
95 *text = "Error parsing matching rule assertion";
96 return SLAPD_DISCONNECT;
100 rc = ber_scanf( ber, "o", &value );
102 if( rc == LBER_ERROR ) {
103 Debug( LDAP_DEBUG_ANY, " get_mra ber_scanf\n", 0, 0, 0 );
104 *text = "Error decoding value in matching rule assertion";
105 return SLAPD_DISCONNECT;
109 * OK, if no matching rule, normalize for equality, otherwise
110 * normalize for the matching rule.
112 rc = value_normalize( ma->ma_desc, SLAP_MR_EQUALITY, &value, &nvalue, text );
113 ch_free( value.bv_val );
115 if( rc != LDAP_SUCCESS ) {
116 ad_free( ma->ma_desc, 1 );
121 ma->ma_value = nvalue;