version 1.50, 2000/07/02 05:18:55
|
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.49 2000/07/01 02:57:54 kurt Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.50 2000/07/02 05:18:55 mrv Exp $ */ |
/* |
/* |
* Copyright 1998-2000 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 28 static int get_substring_filter(
|
Line 28 static int get_substring_filter(
|
char **fstr, |
char **fstr, |
const char **text ); |
const char **text ); |
|
|
static int escape_value( |
static int filter_escape_value( |
struct berval *in, |
struct berval *in, |
struct berval *out ); |
struct berval *out ); |
|
|
Line 107 get_filter(
|
Line 107 get_filter(
|
|
|
assert( f->f_ava != NULL ); |
assert( f->f_ava != NULL ); |
|
|
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
|
|
*fstr = ch_malloc( sizeof("(=)") |
*fstr = ch_malloc( sizeof("(=)") |
+ f->f_av_desc->ad_cname->bv_len |
+ f->f_av_desc->ad_cname->bv_len |
Line 133 get_filter(
|
Line 133 get_filter(
|
break; |
break; |
} |
} |
|
|
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
|
|
*fstr = ch_malloc( sizeof("(>=)") |
*fstr = ch_malloc( sizeof("(>=)") |
+ f->f_av_desc->ad_cname->bv_len |
+ f->f_av_desc->ad_cname->bv_len |
Line 155 get_filter(
|
Line 155 get_filter(
|
} |
} |
|
|
|
|
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
|
|
*fstr = ch_malloc( sizeof("(<=)") |
*fstr = ch_malloc( sizeof("(<=)") |
+ f->f_av_desc->ad_cname->bv_len |
+ f->f_av_desc->ad_cname->bv_len |
Line 204 get_filter(
|
Line 204 get_filter(
|
break; |
break; |
} |
} |
|
|
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
|
|
*fstr = ch_malloc( sizeof("(~=)") |
*fstr = ch_malloc( sizeof("(~=)") |
+ f->f_av_desc->ad_cname->bv_len |
+ f->f_av_desc->ad_cname->bv_len |
Line 451 get_substring_filter(
|
Line 451 get_substring_filter(
|
f->f_sub_initial = value; |
f->f_sub_initial = value; |
|
|
if( fstr ) { |
if( fstr ) { |
escape_value( value, &escaped ); |
filter_escape_value( value, &escaped ); |
*fstr = ch_realloc( *fstr, |
*fstr = ch_realloc( *fstr, |
strlen( *fstr ) + escaped.bv_len + 1 ); |
strlen( *fstr ) + escaped.bv_len + 1 ); |
strcat( *fstr, escaped.bv_val ); |
strcat( *fstr, escaped.bv_val ); |
Line 467 get_substring_filter(
|
Line 467 get_substring_filter(
|
} |
} |
|
|
if( fstr ) { |
if( fstr ) { |
escape_value( value, &escaped ); |
filter_escape_value( value, &escaped ); |
*fstr = ch_realloc( *fstr, |
*fstr = ch_realloc( *fstr, |
strlen( *fstr ) + escaped.bv_len + 2 ); |
strlen( *fstr ) + escaped.bv_len + 2 ); |
strcat( *fstr, "*" ); |
strcat( *fstr, "*" ); |
Line 485 get_substring_filter(
|
Line 485 get_substring_filter(
|
f->f_sub_final = value; |
f->f_sub_final = value; |
|
|
if( fstr ) { |
if( fstr ) { |
escape_value( value, &escaped ); |
filter_escape_value( value, &escaped ); |
*fstr = ch_realloc( *fstr, |
*fstr = ch_realloc( *fstr, |
strlen( *fstr ) + escaped.bv_len + 2 ); |
strlen( *fstr ) + escaped.bv_len + 2 ); |
strcat( *fstr, "*" ); |
strcat( *fstr, "*" ); |
Line 598 filter_print( Filter *f )
|
Line 598 filter_print( Filter *f )
|
|
|
switch ( f->f_choice ) { |
switch ( f->f_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
fprintf( stderr, "(%s=%s)", |
fprintf( stderr, "(%s=%s)", |
f->f_av_desc->ad_cname->bv_val, |
f->f_av_desc->ad_cname->bv_val, |
escaped.bv_val ); |
escaped.bv_val ); |
Line 606 filter_print( Filter *f )
|
Line 606 filter_print( Filter *f )
|
break; |
break; |
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
fprintf( stderr, "(%s>=%s)", |
fprintf( stderr, "(%s>=%s)", |
f->f_av_desc->ad_cname->bv_val, |
f->f_av_desc->ad_cname->bv_val, |
escaped.bv_val ); |
escaped.bv_val ); |
Line 614 filter_print( Filter *f )
|
Line 614 filter_print( Filter *f )
|
break; |
break; |
|
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
fprintf( stderr, "(%s<=%s)", |
fprintf( stderr, "(%s<=%s)", |
f->f_ava->aa_desc->ad_cname->bv_val, |
f->f_ava->aa_desc->ad_cname->bv_val, |
escaped.bv_val ); |
escaped.bv_val ); |
Line 622 filter_print( Filter *f )
|
Line 622 filter_print( Filter *f )
|
break; |
break; |
|
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
escape_value( f->f_av_value, &escaped ); |
filter_escape_value( f->f_av_value, &escaped ); |
fprintf( stderr, "(%s~=%s)", |
fprintf( stderr, "(%s~=%s)", |
f->f_ava->aa_desc->ad_cname->bv_val, |
f->f_ava->aa_desc->ad_cname->bv_val, |
escaped.bv_val ); |
escaped.bv_val ); |
Line 633 filter_print( Filter *f )
|
Line 633 filter_print( Filter *f )
|
fprintf( stderr, "(%s=" /*)*/, |
fprintf( stderr, "(%s=" /*)*/, |
f->f_sub_desc->ad_cname->bv_val ); |
f->f_sub_desc->ad_cname->bv_val ); |
if ( f->f_sub_initial != NULL ) { |
if ( f->f_sub_initial != NULL ) { |
escape_value( f->f_sub_initial, &escaped ); |
filter_escape_value( f->f_sub_initial, &escaped ); |
fprintf( stderr, "%s", |
fprintf( stderr, "%s", |
escaped.bv_val ); |
escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
} |
} |
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++ ) { |
escape_value( f->f_sub_any[i], &escaped ); |
filter_escape_value( f->f_sub_any[i], &escaped ); |
fprintf( stderr, "*%s", |
fprintf( stderr, "*%s", |
escaped.bv_val ); |
escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
} |
} |
} |
} |
if ( f->f_sub_final != NULL ) { |
if ( f->f_sub_final != NULL ) { |
escape_value( f->f_sub_final, &escaped ); |
filter_escape_value( f->f_sub_final, &escaped ); |
fprintf( stderr, |
fprintf( stderr, |
"*%s", escaped.bv_val ); |
"*%s", escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
ber_memfree( escaped.bv_val ); |
Line 688 filter_print( Filter *f )
|
Line 688 filter_print( Filter *f )
|
|
|
#endif /* ldap_debug */ |
#endif /* ldap_debug */ |
|
|
int escape_value( |
int filter_escape_value( |
struct berval *in, |
struct berval *in, |
struct berval *out ) |
struct berval *out ) |
{ |
{ |