From: Kurt Zeilenga Date: Fri, 1 Mar 2002 17:36:22 +0000 (+0000) Subject: Add a value_validate() function to be used by prior to value_normalize X-Git-Tag: OPENLDAP_REL_ENG_2_MP~388 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c0fdb1aaca7801df8bcfa5b1e55151be98cd25c0;p=openldap Add a value_validate() function to be used by prior to value_normalize calls as needed (compare/filters). --- diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 401dc0f080..0da0e1c321 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -942,6 +942,10 @@ LDAP_SLAPD_F (void) slap_init_user LDAP_P(( char *username, char *groupname )); /* * value.c */ +LDAP_SLAPD_F (int) value_validate LDAP_P(( + MatchingRule *mr, + struct berval *in, + const char ** text )); LDAP_SLAPD_F (int) value_normalize LDAP_P(( AttributeDescription *ad, unsigned usage, diff --git a/servers/slapd/value.c b/servers/slapd/value.c index c3c0b0d472..3391849236 100644 --- a/servers/slapd/value.c +++ b/servers/slapd/value.c @@ -53,6 +53,38 @@ value_add( return LDAP_SUCCESS; } +int +value_validate( + MatchingRule *mr, + struct berval *in, + const char **text ) +{ + int rc; + + if( mr == NULL ) { + *text = "inappropriate matching request"; + return LDAP_INAPPROPRIATE_MATCHING; + } + + if( mr->smr_syntax == NULL ) { + *text = "no assertion syntax"; + return LDAP_INVALID_SYNTAX; + } + + if( ! mr->smr_syntax->ssyn_validate ) { + *text = "no syntax validator"; + return LDAP_INVALID_SYNTAX; + } + + rc = (mr->smr_syntax->ssyn_validate)( mr->smr_syntax, in ); + + if( rc != LDAP_SUCCESS ) { + *text = "value is invalid"; + return LDAP_INVALID_SYNTAX; + } + + return LDAP_SUCCESS; +} int value_normalize(