version 1.13.4.12, 2002/08/26 10:36:59
|
version 1.51, 2000/07/02 15:14:37
|
Line 1
|
Line 1
|
/* filter.c - routines for parsing and dealing with filters */ |
/* filter.c - routines for parsing and dealing with filters */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.13.4.11 2002/01/04 20:38:28 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.50 2000/07/02 05:18:55 mrv Exp $ */ |
/* |
/* |
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved. |
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file |
*/ |
*/ |
|
|
Line 183 get_filter(
|
Line 183 get_filter(
|
err = slap_bv2ad( &type, &f->f_desc, text ); |
err = slap_bv2ad( &type, &f->f_desc, text ); |
|
|
if( err != LDAP_SUCCESS ) { |
if( err != LDAP_SUCCESS ) { |
/* unrecognized attribute description or other error */ |
|
f->f_choice = SLAPD_FILTER_COMPUTED; |
|
f->f_result = LDAP_COMPARE_FALSE; |
|
*fstr = ch_strdup( "(unrecogized=*)" ); |
|
ch_free( type.bv_val ); |
ch_free( type.bv_val ); |
err = LDAP_SUCCESS; |
|
break; |
break; |
} |
} |
|
|
Line 262 get_filter(
|
Line 257 get_filter(
|
case LDAP_FILTER_EXT: |
case LDAP_FILTER_EXT: |
/* not yet implemented */ |
/* not yet implemented */ |
Debug( LDAP_DEBUG_ANY, "extensible match not yet implemented.\n", |
Debug( LDAP_DEBUG_ANY, "extensible match not yet implemented.\n", |
0, 0, 0 ); |
f->f_choice, 0, 0 ); |
(void) ber_skip_tag( ber, &len ); |
(void) ber_skip_tag( ber, &len ); |
f->f_choice = SLAPD_FILTER_COMPUTED; |
f->f_choice = SLAPD_FILTER_COMPUTED; |
f->f_result = SLAPD_COMPARE_UNDEFINED; |
f->f_result = SLAPD_COMPARE_UNDEFINED; |
Line 270 get_filter(
|
Line 265 get_filter(
|
break; |
break; |
|
|
default: |
default: |
(void) ber_scanf( ber, "x" ); /* skip the element */ |
(void) ber_skip_tag( ber, &len ); |
Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", |
Debug( LDAP_DEBUG_ANY, "get_filter: unknown filter type=%lu\n", |
f->f_choice, 0, 0 ); |
f->f_choice, 0, 0 ); |
f->f_choice = SLAPD_FILTER_COMPUTED; |
f->f_choice = SLAPD_FILTER_COMPUTED; |
Line 448 get_substring_filter(
|
Line 443 get_substring_filter(
|
switch ( tag ) { |
switch ( tag ) { |
case LDAP_SUBSTRING_INITIAL: |
case LDAP_SUBSTRING_INITIAL: |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " INITIAL\n", 0, 0, 0 ); |
if ( f->f_sub_initial != NULL |
if ( f->f_sub_initial != NULL ) { |
|| f->f_sub_any != NULL |
|
|| f->f_sub_final != NULL ) |
|
{ |
|
ber_bvfree( value ); |
ber_bvfree( value ); |
goto return_error; |
goto return_error; |
} |
} |
Line 469 get_substring_filter(
|
Line 461 get_substring_filter(
|
|
|
case LDAP_SUBSTRING_ANY: |
case LDAP_SUBSTRING_ANY: |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " ANY\n", 0, 0, 0 ); |
|
|
if ( f->f_sub_final != NULL ) { |
|
ber_bvfree( value ); |
|
goto return_error; |
|
} |
|
|
|
if( ber_bvecadd( &f->f_sub_any, value ) < 0 ) { |
if( ber_bvecadd( &f->f_sub_any, value ) < 0 ) { |
ber_bvfree( value ); |
ber_bvfree( value ); |
goto return_error; |
goto return_error; |
Line 492 get_substring_filter(
|
Line 478 get_substring_filter(
|
|
|
case LDAP_SUBSTRING_FINAL: |
case LDAP_SUBSTRING_FINAL: |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, " FINAL\n", 0, 0, 0 ); |
|
|
if ( f->f_sub_final != NULL ) { |
if ( f->f_sub_final != NULL ) { |
ber_bvfree( value ); |
ber_bvfree( value ); |
goto return_error; |
goto return_error; |
} |
} |
|
|
f->f_sub_final = value; |
f->f_sub_final = value; |
|
|
if( fstr ) { |
if( fstr ) { |
Line 577 filter_free( Filter *f )
|
Line 561 filter_free( Filter *f )
|
if ( f->f_sub_final != NULL ) { |
if ( f->f_sub_final != NULL ) { |
ber_bvfree( f->f_sub_final ); |
ber_bvfree( f->f_sub_final ); |
} |
} |
ch_free( f->f_sub ); |
|
break; |
break; |
|
|
case LDAP_FILTER_AND: |
case LDAP_FILTER_AND: |
Line 654 filter_print( Filter *f )
|
Line 637 filter_print( Filter *f )
|
fprintf( stderr, "%s", |
fprintf( stderr, "%s", |
escaped.bv_val ); |
escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
i = 1; |
|
} |
} |
if ( f->f_sub_any != NULL ) { |
if ( f->f_sub_any != NULL ) { |
for ( i = 0; f->f_sub_any[i] != NULL; i++ ) { |
for ( i = 0; f->f_sub_any[i] != NULL; i++ ) { |
Line 669 filter_print( Filter *f )
|
Line 651 filter_print( Filter *f )
|
fprintf( stderr, |
fprintf( stderr, |
"*%s", escaped.bv_val ); |
"*%s", escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
i = 0; |
|
} |
} |
if ( i ) fprintf( stderr, "*" ); |
|
fprintf( stderr, /*(*/ ")" ); |
fprintf( stderr, /*(*/ ")" ); |
break; |
break; |
|
|
Line 719 int filter_escape_value(
|
Line 699 int filter_escape_value(
|
out->bv_val = (char *) ch_malloc( ( in->bv_len * 3 ) + 1 ); |
out->bv_val = (char *) ch_malloc( ( in->bv_len * 3 ) + 1 ); |
out->bv_len = 0; |
out->bv_len = 0; |
|
|
|
#undef NIBBLE |
|
#undef ESCAPE_LO |
|
#undef ESCAPE_HI |
|
#define NIBBLE(c) ((c)&0x0f) |
|
#define ESCAPE_LO(c) ( NIBBLE(c) + ( NIBBLE(c) < 10 ? '0' : 'A' - 10 ) ) |
|
#define ESCAPE_HI(c) ( ESCAPE_LO((c)>>4) ) |
|
|
for( i=0; i < in->bv_len ; i++ ) { |
for( i=0; i < in->bv_len ; i++ ) { |
if( FILTER_ESCAPE(in->bv_val[i]) ) { |
if( FILTER_ESCAPE(in->bv_val[i]) ) { |
out->bv_val[out->bv_len++] = SLAP_ESCAPE_CHAR; |
out->bv_val[out->bv_len++] = '\\'; |
out->bv_val[out->bv_len++] = SLAP_ESCAPE_HI( in->bv_val[i] ); |
out->bv_val[out->bv_len++] = ESCAPE_HI( in->bv_val[i] ); |
out->bv_val[out->bv_len++] = SLAP_ESCAPE_LO( in->bv_val[i] ); |
out->bv_val[out->bv_len++] = ESCAPE_LO( in->bv_val[i] ); |
} else { |
} else { |
out->bv_val[out->bv_len++] = in->bv_val[i]; |
out->bv_val[out->bv_len++] = in->bv_val[i]; |
} |
} |
Line 732 int filter_escape_value(
|
Line 719 int filter_escape_value(
|
out->bv_val[out->bv_len] = '\0'; |
out->bv_val[out->bv_len] = '\0'; |
return LDAP_SUCCESS; |
return LDAP_SUCCESS; |
} |
} |
|
|
|
|