}
if( slapMode & SLAP_TOOL_MODE ) {
+ struct berval *pval;
slap_syntax_validate_func *validate =
ad->ad_type->sat_syntax->ssyn_validate;
+ slap_syntax_transform_func *pretty =
+ ad->ad_type->sat_syntax->ssyn_pretty;
- if( !validate ) {
+ if( pretty ) {
+ rc = pretty( ad->ad_type->sat_syntax,
+ &value, &pval );
+
+ } else if( validate ) {
+ /*
+ * validate value per syntax
+ */
+ rc = validate( ad->ad_type->sat_syntax, &value );
+
+ } else {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_INFO,
"str2entry: no validator for syntax %s\n",
return NULL;
}
- /*
- * validate value per syntax
- */
- rc = validate( ad->ad_type->sat_syntax, &value );
-
if( rc != 0 ) {
#ifdef NEW_LOGGING
LDAP_LOG(( "operation", LDAP_LEVEL_ERR,
free( type );
return NULL;
}
+
+ if( pretty ) {
+ free( value.bv_val );
+ value = *pval;
+ free( pval );
+ }
}
rc = attr_merge( e, ad, vals );
ber_len_t nvals;
slap_syntax_validate_func *validate =
ad->ad_type->sat_syntax->ssyn_validate;
-
- if( !validate ) {
+ slap_syntax_transform_func *pretty =
+ ad->ad_type->sat_syntax->ssyn_pretty;
+
+ if( !pretty && !validate ) {
slap_mods_free( mod );
*text = "no validator for syntax";
snprintf( textbuf, textlen,
/*
* check that each value is valid per syntax
+ * and pretty if appropriate
*/
for( nvals = 0; ml->ml_bvalues[nvals]; nvals++ ) {
- rc = validate( ad->ad_type->sat_syntax, ml->ml_bvalues[nvals] );
+ struct berval *pval;
+ if( pretty ) {
+ rc = pretty( ad->ad_type->sat_syntax,
+ ml->ml_bvalues[nvals], &pval );
+ } else {
+ rc = validate( ad->ad_type->sat_syntax,
+ ml->ml_bvalues[nvals] );
+ }
if( rc != 0 ) {
slap_mods_free( mod );
*text = textbuf;
return LDAP_INVALID_SYNTAX;
}
+
+ if( pretty ) {
+ ber_memfree( ml->ml_bvalues[nvals]->bv_val );
+ *ml->ml_bvalues[nvals] = *pval;
+ free( pval );
+ }
}
/*
dnPretty(
Syntax *syntax,
struct berval *val,
- struct berval **normalized)
+ struct berval **pretty)
{
struct berval *out = NULL;
out = ber_bvdup( val );
}
- *normalized = out;
+ *pretty = out;
return( LDAP_SUCCESS );
}