]> git.sur5r.net Git - openldap/commitdiff
Implemented slapi_filter_apply() API
authorLuke Howard <lukeh@openldap.org>
Thu, 30 Jan 2003 12:24:53 +0000 (12:24 +0000)
committerLuke Howard <lukeh@openldap.org>
Thu, 30 Jan 2003 12:24:53 +0000 (12:24 +0000)
servers/slapd/slapi/proto-slapi.h
servers/slapd/slapi/slapi_utils.c

index 81215a90015943bab15ee82e14151f41d550daa2..31d9a2add082a6e462a147c058c3845803a650cd 100644 (file)
@@ -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);
index 3c5e758f3d44b2b92426f8189cc036db69ac3fa8..7605797db255d8ad9753bd540ba62a8b2e4316f7 100644 (file)
@@ -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,