- return( NULL );
- }
-
- str = freeme = ch_strdup( str );
-
- switch ( *str ) {
- case '(':
- if ( (end = find_matching_paren( str )) == NULL ) {
- filter_free( f );
- free( freeme );
- return( NULL );
- }
- *end = '\0';
-
- str++;
- switch ( *str ) {
- case '&':
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
- "str2filter: AND\n" ));
-#else
- Debug( LDAP_DEBUG_FILTER, "str2filter: AND\n",
- 0, 0, 0 );
-#endif
-
-
- str++;
- f = str2list( str, LDAP_FILTER_AND );
- break;
-
- case '|':
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
- "str2filter: OR\n" ));
-#else
- Debug( LDAP_DEBUG_FILTER, "put_filter: OR\n",
- 0, 0, 0 );
-#endif
-
-
- str++;
- f = str2list( str, LDAP_FILTER_OR );
- break;
-
- case '!':
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
- "str2filter: NOT\n" ));
-#else
- Debug( LDAP_DEBUG_FILTER, "put_filter: NOT\n",
- 0, 0, 0 );
-#endif
-
-
- str++;
- f = str2list( str, LDAP_FILTER_NOT );
- break;
-
- default:
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
- "str2filter: simple\n" ));
-#else
- Debug( LDAP_DEBUG_FILTER, "str2filter: simple\n",
- 0, 0, 0 );
-#endif
-
-
- f = str2simple( str );
- break;
- }
- *end = ')';
- break;
-
- default: /* assume it's a simple type=value filter */
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_DETAIL1,
- "str2filter: default\n" ));
-#else
- Debug( LDAP_DEBUG_FILTER, "str2filter: default\n", 0, 0,
- 0 );
-#endif
-
-
- f = str2simple( str );
- break;
- }
-
- free( freeme );
- return( f );
-}
-
-/*
- * Put a list of filters like this "(filter1)(filter2)..."
- */
-
-static Filter *
-str2list( const char *str, unsigned long ftype )
-{
- Filter *f;
- Filter **fp;
- char *next;
- char save;
-
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
- "str2list: \"%s\"\n", str ));
-#else
- Debug( LDAP_DEBUG_FILTER, "str2list \"%s\"\n", str, 0, 0 );
-#endif
-
-
- f = (Filter *) ch_calloc( 1, sizeof(Filter) );
- f->f_choice = ftype;
- fp = &f->f_list;
-
- while ( *str ) {
- while ( *str && isspace( (unsigned char) *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( const char *str )
-{
- Filter *f;
- char *s;
- char *value, savechar;
- int rc;
- const char *text;
-
-#ifdef NEW_LOGGING
- LDAP_LOG(( "filter", LDAP_LEVEL_ENTRY,
- "str2simple: \"%s\"\n", str ));
-#else
- Debug( LDAP_DEBUG_FILTER, "str2simple \"%s\"\n", str, 0, 0 );
-#endif
-
-
- if ( (s = strchr( str, '=' )) == NULL ) {
- return( NULL );