- 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 ( ldap_pvt_find_wildcard( 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 = ch_strdup( str );
- if ( str2subvals( value, f ) != 0 ) {
- filter_free( f );
- *(value-1) = '=';
- return( NULL );
- }
- *(value-1) = '=';
- return( f );
- }
- break;
- }
-
- if ( f->f_choice == LDAP_FILTER_PRESENT ) {
- f->f_type = ch_strdup( str );
- } else {
- f->f_avtype = ch_strdup( str );
- f->f_avvalue.bv_val = ch_strdup( value );
- ldap_pvt_filter_value_unescape( f->f_avvalue.bv_val );
- f->f_avvalue.bv_len = strlen( value );
- }