version 1.158, 2011/01/12 13:41:34
|
version 1.159, 2011/01/29 11:29:20
|
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.156 2010/08/29 14:27:08 ando Exp $ */ |
/* $OpenLDAP: pkg/ldap/servers/slapd/filter.c,v 1.158 2011/01/12 13:41:34 hallvard Exp $ */ |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
/* This work is part of OpenLDAP Software <http://www.openldap.org/>. |
* |
* |
* Copyright 1998-2011 The OpenLDAP Foundation. |
* Copyright 1998-2011 The OpenLDAP Foundation. |
Line 586 filter_free( Filter *f )
|
Line 586 filter_free( Filter *f )
|
void |
void |
filter2bv_x( Operation *op, Filter *f, struct berval *fstr ) |
filter2bv_x( Operation *op, Filter *f, struct berval *fstr ) |
{ |
{ |
|
return filter2bv_undef_x( op, f, 0, fstr ); |
|
} |
|
|
|
void |
|
filter2bv_undef_x( Operation *op, Filter *f, int noundef, struct berval *fstr ) |
|
{ |
int i; |
int i; |
Filter *p; |
Filter *p; |
struct berval tmp, value; |
struct berval tmp, value; |
Line 598 filter2bv_x( Operation *op, Filter *f, s
|
Line 604 filter2bv_x( Operation *op, Filter *f, s
|
ber_bvnone = BER_BVC( "(?=none)" ); |
ber_bvnone = BER_BVC( "(?=none)" ); |
ber_len_t len; |
ber_len_t len; |
ber_tag_t choice; |
ber_tag_t choice; |
int undef; |
int undef, undef2; |
char *sign; |
char *sign; |
|
|
if ( f == NULL ) { |
if ( f == NULL ) { |
Line 607 filter2bv_x( Operation *op, Filter *f, s
|
Line 613 filter2bv_x( Operation *op, Filter *f, s
|
} |
} |
|
|
undef = f->f_choice & SLAPD_FILTER_UNDEFINED; |
undef = f->f_choice & SLAPD_FILTER_UNDEFINED; |
|
undef2 = (undef && !noundef); |
choice = f->f_choice & SLAPD_FILTER_MASK; |
choice = f->f_choice & SLAPD_FILTER_MASK; |
|
|
switch ( choice ) { |
switch ( choice ) { |
Line 644 simple:
|
Line 651 simple:
|
* is legal for that attribute's syntax */ |
* is legal for that attribute's syntax */ |
|
|
fstr->bv_len += f->f_av_desc->ad_cname.bv_len + tmp.bv_len; |
fstr->bv_len += f->f_av_desc->ad_cname.bv_len + tmp.bv_len; |
if ( undef ) |
if ( undef2 ) |
fstr->bv_len++; |
fstr->bv_len++; |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s)", |
undef ? "?" : "", |
undef2 ? "?" : "", |
f->f_av_desc->ad_cname.bv_val, sign, |
f->f_av_desc->ad_cname.bv_val, sign, |
tmp.bv_len ? tmp.bv_val : "" ); |
tmp.bv_len ? tmp.bv_val : "" ); |
|
|
Line 663 simple:
|
Line 670 simple:
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
fstr->bv_len = f->f_sub_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_sub_desc->ad_cname.bv_len + |
STRLENOF("(=*)"); |
STRLENOF("(=*)"); |
if ( undef ) |
if ( undef2 ) |
fstr->bv_len++; |
fstr->bv_len++; |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 128, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", |
undef ? "?" : "", |
undef2 ? "?" : "", |
f->f_sub_desc->ad_cname.bv_val ); |
f->f_sub_desc->ad_cname.bv_val ); |
|
|
if ( f->f_sub_initial.bv_val != NULL ) { |
if ( f->f_sub_initial.bv_val != NULL ) { |
Line 737 simple:
|
Line 744 simple:
|
case LDAP_FILTER_PRESENT: |
case LDAP_FILTER_PRESENT: |
fstr->bv_len = f->f_desc->ad_cname.bv_len + |
fstr->bv_len = f->f_desc->ad_cname.bv_len + |
STRLENOF("(=*)"); |
STRLENOF("(=*)"); |
if ( undef ) |
if ( undef2 ) |
fstr->bv_len++; |
fstr->bv_len++; |
|
|
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s=*)", |
undef ? "?" : "", |
undef2 ? "?" : "", |
f->f_desc->ad_cname.bv_val ); |
f->f_desc->ad_cname.bv_val ); |
break; |
break; |
|
|
Line 760 simple:
|
Line 767 simple:
|
for ( p = f->f_list; p != NULL; p = p->f_next ) { |
for ( p = f->f_list; p != NULL; p = p->f_next ) { |
len = fstr->bv_len; |
len = fstr->bv_len; |
|
|
filter2bv_x( op, p, &tmp ); |
filter2bv_undef_x( op, p, noundef, &tmp ); |
|
|
fstr->bv_len += tmp.bv_len; |
fstr->bv_len += tmp.bv_len; |
fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, |
fstr->bv_val = op->o_tmprealloc( fstr->bv_val, fstr->bv_len + 1, |
Line 792 simple:
|
Line 799 simple:
|
} |
} |
|
|
fstr->bv_len = ad.bv_len + |
fstr->bv_len = ad.bv_len + |
|
( undef2 ? 1 : 0 ) + |
( f->f_mr_dnattrs ? STRLENOF(":dn") : 0 ) + |
( f->f_mr_dnattrs ? STRLENOF(":dn") : 0 ) + |
( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len+1 : 0 ) + |
( f->f_mr_rule_text.bv_len ? f->f_mr_rule_text.bv_len + STRLENOF(":") : 0 ) + |
tmp.bv_len + STRLENOF("(:=)"); |
tmp.bv_len + STRLENOF("(:=)"); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
fstr->bv_val = op->o_tmpalloc( fstr->bv_len + 1, op->o_tmpmemctx ); |
|
|
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s%s:=%s)", |
snprintf( fstr->bv_val, fstr->bv_len + 1, "(%s%s%s%s%s:=%s)", |
undef ? "?" : "", |
undef2 ? "?" : "", |
ad.bv_val, |
ad.bv_val, |
f->f_mr_dnattrs ? ":dn" : "", |
f->f_mr_dnattrs ? ":dn" : "", |
f->f_mr_rule_text.bv_len ? ":" : "", |
f->f_mr_rule_text.bv_len ? ":" : "", |
Line 838 simple:
|
Line 846 simple:
|
void |
void |
filter2bv( Filter *f, struct berval *fstr ) |
filter2bv( Filter *f, struct berval *fstr ) |
{ |
{ |
|
return filter2bv_undef( f, 0, fstr ); |
|
} |
|
|
|
void |
|
filter2bv_undef( Filter *f, int noundef, struct berval *fstr ) |
|
{ |
Operation op; |
Operation op; |
Opheader ohdr; |
Opheader ohdr; |
|
|
Line 845 filter2bv( Filter *f, struct berval *fst
|
Line 859 filter2bv( Filter *f, struct berval *fst
|
op.o_tmpmemctx = NULL; |
op.o_tmpmemctx = NULL; |
op.o_tmpmfuncs = &ch_mfuncs; |
op.o_tmpmfuncs = &ch_mfuncs; |
|
|
filter2bv_x( &op, f, fstr ); |
filter2bv_undef_x( &op, f, noundef, fstr ); |
} |
} |
|
|
Filter * |
Filter * |