- return( f );
-}
-
-/*
- * Put a list of filters like this "(filter1)(filter2)..."
- */
-
-static Filter *
-str2list( char *str, unsigned long ftype )
-{
- Filter *f;
- Filter **fp;
- char *next;
- char save;
-
- Debug( LDAP_DEBUG_FILTER, "str2list \"%s\"\n", str, 0, 0 );
-
- f = (Filter *) ch_calloc( 1, sizeof(Filter) );
- f->f_choice = ftype;
- fp = &f->f_list;
-
- while ( *str ) {
- while ( *str && isspace( *str ) )
- str++;
- if ( *str == '\0' )
- break;
-
- if ( (next = find_matching_paren( str )) == NULL ) {
- filter_free( f );
- return( NULL );
- }
- save = *++next;
- *next = '\0';
-
- /* now we have "(filter)" with str pointing to it */
- if ( (*fp = str2filter( str )) == NULL ) {
- filter_free( f );
- *next = save;
- return( NULL );
- }
- *next = save;
-
- str = next;
- fp = &(*fp)->f_next;
- }
- *fp = NULL;
-
- return( f );
-}
-
-static Filter *
-str2simple( char *str )
-{
- Filter *f;
- char *s;
- char *value, savechar;
-
- Debug( LDAP_DEBUG_FILTER, "str2simple \"%s\"\n", str, 0, 0 );
-
- if ( (s = strchr( str, '=' )) == NULL ) {
- return( NULL );
- }
- value = s + 1;
- *s-- = '\0';
- savechar = *s;
-
- f = (Filter *) ch_calloc( 1, sizeof(Filter) );
-
- switch ( *s ) {
- case '<':
- f->f_choice = LDAP_FILTER_LE;
- *s = '\0';
- break;
- case '>':
- f->f_choice = LDAP_FILTER_GE;
- *s = '\0';
- break;
- case '~':
- f->f_choice = LDAP_FILTER_APPROX;
- *s = '\0';
- break;
- default:
- if ( strchr( value, '*' ) == NULL ) {
- f->f_choice = LDAP_FILTER_EQUALITY;
- } else if ( strcmp( value, "*" ) == 0 ) {
- f->f_choice = LDAP_FILTER_PRESENT;
- } else {
- f->f_choice = LDAP_FILTER_SUBSTRINGS;
- f->f_sub_type = strdup( str );
- if ( str2subvals( value, f ) != 0 ) {
- filter_free( f );
- *(value-1) = '=';
- return( NULL );
- }
- *(value-1) = '=';
- return( f );
- }
- break;