From: Luke Howard Date: Tue, 19 Jul 2005 06:55:56 +0000 (+0000) Subject: Add slapi_x_filter_set_attribute_type() API X-Git-Tag: OPENLDAP_AC_BP~338 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5eda803bc13b6d33a2ec571ffbf194cdc5c4d1ab;p=openldap Add slapi_x_filter_set_attribute_type() API --- diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 22ec538b74..6839516162 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -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); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 9b6288b924..503234385a 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -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 )