]> git.sur5r.net Git - openldap/commitdiff
Add a value_validate() function to be used by prior to value_normalize
authorKurt Zeilenga <kurt@openldap.org>
Fri, 1 Mar 2002 17:36:22 +0000 (17:36 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 1 Mar 2002 17:36:22 +0000 (17:36 +0000)
calls as needed (compare/filters).

servers/slapd/proto-slap.h
servers/slapd/value.c

index 401dc0f0808dff8a9e046ae387cf7da53d1d6196..0da0e1c3215d2c3d9e3072f56509410d04605b55 100644 (file)
@@ -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,
index c3c0b0d47257a1044244ad77e05cc5d6e448ed9e..3391849236fc2711ceb92aec66f20c5185abea4c 100644 (file)
@@ -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(