/* value.c - routines for dealing with values */
/* $OpenLDAP$ */
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2003 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
+ */
/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ * Copyright (c) 1995 Regents of the University of Michigan.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that this notice is preserved and that due credit is given
+ * to the University of Michigan at Ann Arbor. The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission. This software
+ * is provided ``as is'' without express or implied warranty.
*/
#include "portable.h"
void *ctx )
{
int rc;
+ struct berval pval;
+ pval.bv_val = NULL;
/* we expect the value to be in the assertion syntax */
assert( !SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) );
return LDAP_INAPPROPRIATE_MATCHING;
}
- rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
+ if( mr->smr_syntax->ssyn_pretty ) {
+ rc = (mr->smr_syntax->ssyn_pretty)( mr->smr_syntax, in, &pval, ctx );
+ in = &pval;
+
+ } else {
+ rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in );
+ }
if( rc != LDAP_SUCCESS ) {
*text = "value does not conform to assertion syntax";
}
if( mr->smr_normalize ) {
- rc = (mr->smr_normalize)( usage,
+ rc = (mr->smr_normalize)(
+ usage|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
ad ? ad->ad_type->sat_syntax : NULL,
mr, in, out, ctx );
+ if( pval.bv_val ) ber_memfree_x( pval.bv_val, ctx );
+
if( rc != LDAP_SUCCESS ) {
*text = "unable to normalize value for matching";
return LDAP_INVALID_SYNTAX;
}
+ } else if ( pval.bv_val != NULL ) {
+ *out = pval;
+
} else {
ber_dupbv_x( out, in, ctx );
}
return LDAP_INAPPROPRIATE_MATCHING;
}
-
rc = (mr->smr_match)( match, flags,
ad->ad_type->sat_syntax,
mr,
mr->smr_normalize )
{
rc = (mr->smr_normalize)(
- flags & SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK,
+ flags & (SLAP_MR_TYPE_MASK|SLAP_MR_SUBTYPE_MASK|SLAP_MR_VALUE_OF_SYNTAX),
ad ? ad->ad_type->sat_syntax : NULL,
mr, val, &nval, ctx );
&vals[i], nval.bv_val == NULL ? val : &nval, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
- free( nval.bv_val );
- return LDAP_SUCCESS;
+ sl_free( nval.bv_val, ctx );
+ return rc;
}
}
- ber_memfree_x( nval.bv_val, ctx );
+ sl_free( nval.bv_val, ctx );
return LDAP_NO_SUCH_ATTRIBUTE;
}