From: Luke Howard Date: Thu, 30 Jan 2003 12:24:53 +0000 (+0000) Subject: Implemented slapi_filter_apply() API X-Git-Tag: NO_SLAP_OP_BLOCKS~471 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a0da326c97b2ed185fa3e84342e1bfde026a36f0;p=openldap Implemented slapi_filter_apply() API --- diff --git a/servers/slapd/slapi/proto-slapi.h b/servers/slapd/slapi/proto-slapi.h index 81215a9001..31d9a2add0 100644 --- a/servers/slapd/slapi/proto-slapi.h +++ b/servers/slapd/slapi/proto-slapi.h @@ -187,6 +187,7 @@ int slapi_filter_get_subfilt( Slapi_Filter *f, char **type, char **initial, Slapi_Filter *slapi_filter_join( int ftype, Slapi_Filter *f1, Slapi_Filter *f2); int slapi_filter_test( Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Filter *f, int verify_access ); +int slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ); int slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f); void slapi_free_search_results_internal(Slapi_PBlock *pb); int slapi_is_connection_ssl(Slapi_PBlock *pPB, int *isSSL); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 3c5e758f3d..7605797db2 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -1641,6 +1641,53 @@ slapi_filter_test_simple( Slapi_Entry *e, Slapi_Filter *f) #endif } +int +slapi_filter_apply( Slapi_Filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code ) +{ +#ifdef LDAP_SLAPI + switch ( f->f_choice ) { + case LDAP_FILTER_AND: + case LDAP_FILTER_NOT: + case LDAP_FILTER_OR: { + int rc; + Filter *f; + + for ( f = f->f_list; f != NULL; f = f->f_next ) { + rc = slapi_filter_apply( f, fn, arg, error_code ); + if ( rc != 0 ) { + return rc; + } + if ( *error_code == SLAPI_FILTER_SCAN_NOMORE ) { + break; + } + } + break; + } + case LDAP_FILTER_EQUALITY: + case LDAP_FILTER_SUBSTRINGS: + case LDAP_FILTER_GE: + case LDAP_FILTER_LE: + case LDAP_FILTER_PRESENT: + case LDAP_FILTER_APPROX: + case LDAP_FILTER_EXT: + *error_code = fn( f, arg ); + break; + default: + *error_code = SLAPI_FILTER_UNKNOWN_FILTER_TYPE; + } + + if ( *error_code == SLAPI_FILTER_SCAN_NOMORE || + *error_code == SLAPI_FILTER_SCAN_CONTINUE ) { + return 0; + } + + return -1; +#else + *error_code = SLAPI_FILTER_UNKNOWN_FILTER_TYPE; + return -1; +#endif +} + int slapi_send_ldap_extended_response( Connection *conn,