]> git.sur5r.net Git - openldap/commitdiff
Add slapi_x_filter_set_attribute_type() API
authorLuke Howard <lukeh@openldap.org>
Tue, 19 Jul 2005 06:55:56 +0000 (06:55 +0000)
committerLuke Howard <lukeh@openldap.org>
Tue, 19 Jul 2005 06:55:56 +0000 (06:55 +0000)
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi_utils.c

index 22ec538b74715f27f127152092fb53ea12a2ca12..68395161622c3ca10379ca54c4c1369743f26ef1 100644 (file)
@@ -211,6 +211,7 @@ extern int slapi_filter_get_ava( Slapi_Filter *f, char **type, struct berval **b
 extern Slapi_Filter *slapi_filter_list_first( Slapi_Filter *f );
 extern Slapi_Filter *slapi_filter_list_next( Slapi_Filter *f, Slapi_Filter *fprev );
 extern int slapi_filter_get_attribute_type( Slapi_Filter *f, char **type ); 
+extern int slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type );
 extern int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
        char ***any, char **final );
 extern Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2);
index 9b6288b924ae80266a26cff4e16d9cadb64a1da2..503234385a26937a8a9eebe95dc3fe2d09bf9ca2 100644 (file)
@@ -1938,6 +1938,49 @@ slapi_filter_get_attribute_type( Slapi_Filter *f, char **type )
 #endif /* LDAP_SLAPI */
 }
 
+int
+slapi_x_filter_set_attribute_type( Slapi_Filter *f, const char *type )
+{
+#ifdef LDAP_SLAPI
+       AttributeDescription **adp, *ad = NULL;
+       const char *text;
+       int rc;
+
+       if ( f == NULL ) {
+               return -1;
+       }
+
+       switch ( f->f_choice ) {
+       case LDAP_FILTER_GE:
+       case LDAP_FILTER_LE:
+       case LDAP_FILTER_EQUALITY:
+       case LDAP_FILTER_APPROX:
+               adp = &f->f_av_desc;
+               break;
+       case LDAP_FILTER_SUBSTRINGS:
+               adp = &f->f_sub_desc;
+               break;
+       case LDAP_FILTER_PRESENT:
+               adp = &f->f_desc;
+               break;
+       case LDAP_FILTER_EXT:
+               adp = &f->f_mr_desc;
+               break;
+       default:
+               /* Complex filters need not apply. */
+               return -1;
+       }
+
+       rc = slap_str2ad( type, &ad, &text );
+       if ( rc == LDAP_SUCCESS )
+               *adp = ad;
+
+       return ( rc == LDAP_SUCCESS ) ? 0 : -1;
+#else
+       return -1;
+#endif /* LDAP_SLAPI */
+}
+
 int
 slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial,
        char ***any, char **final )