Chapter 26. Functions for Dealing with Filters

This chapter contains reference information on filter routines.

Table 26.1. Filter Routines

Function Description
slapi_filter_apply() Applies a function to each simple filter component within a complex filter.
slapi_filter_compare() Determines if two filters are identical.
slapi_filter_dup() Duplicates the specified filter.
slapi_filter_free() Frees the specified filter.
slapi_filter_get_attribute_type() Gets the attribute type for all simple filter choices.
slapi_filter_get_ava() Gets the attribute type and the value from the filter.
slapi_filter_get_choice() Gets the type of the specified filter.
slapi_filter_get_subfilt() Gets the substring values from the filter.
slapi_filter_get_type() Gets the attribute type specified in the filter.
slapi_filter_join() Joins two specified filters.
slapi_filter_join_ex() Recursively joins two specified filters.
slapi_filter_list_first() Gets the first filter that makes up the specified filter.
slapi_filter_list_next() Gets the next filter.
slapi_filter_test() Determines if the specified entry matches a particular filter.
slapi_filter_test_ext() Determines if an entry matches a given filter.
slapi_filter_test_simple() Determines if an entry matches a filter.
slapi_find_matching_paren() Finds the matching right parentheses in a string, corresponding to the left parenthesis to which the string currently points.
slapi_str2filter() Converts a string description of a search filter into a filter of the Slapi_Filter type.
slapi_vattr_filter_test() Tests a filter against a single entry.

26.1. slapi_filter_apply()

Applies a function to each simple filter component within a complex filter; a simple filter is anything other than AND, OR, or NOT.
Syntax

#include "slapi-plugin.h"
int slapi_filter_apply( struct slapi_filter *f, FILTER_APPLY_FN fn, void *arg, int *error_code );

Parameters

This function takes the following parameters:

f
Filter on which the function is to be applied.
fn
Function to apply.
arg
Argument to the function (fn).
error_code
Pointer to error code of fn, which can be accessed by calling function. Possible values slapi_filter_apply() may set in error_code include SLAPI_FILTER_UNKNOWN_FILTER_TYPE. A FILTER_APPLY_FN should return _STOP or _CONTINUE only.
Returns

This function returns an integer. Possible return values for slapi_filter_apply() include:

  • SLAPI_FILTER_SCAN_NOMORE indicates success in traversing the entire filter.
  • SLAPI_FILTER_SCAN_STOP indicates premature abort.
  • SLAPI_FILTER_SCAN_CONTINUE indicates continue scanning.
  • SLAPI_FILTER_SCAN_ERROR indicates an occurred during the traverse and the scan is aborted. In this case, error_code can be checked for more details; currently, the only error is SLAPI_FILTER_UNKNOWN_FILTER_TYPE.