version 1.12, 1999/06/28 22:03:34
|
version 1.13, 1999/07/07 16:51:39
|
Line 34 get_filter( Connection *conn, BerElement
|
Line 34 get_filter( Connection *conn, BerElement
|
* lessOrEqual [6] AttributeValueAssertion, |
* lessOrEqual [6] AttributeValueAssertion, |
* present [7] AttributeType,, |
* present [7] AttributeType,, |
* approxMatch [8] AttributeValueAssertion |
* approxMatch [8] AttributeValueAssertion |
|
* extensibleMatch [9] MatchingRuleAssertion |
* } |
* } |
* |
* |
* SubstringFilter ::= SEQUENCE { |
* SubstringFilter ::= SEQUENCE { |
Line 44 get_filter( Connection *conn, BerElement
|
Line 45 get_filter( Connection *conn, BerElement
|
* final [2] IA5String |
* final [2] IA5String |
* } |
* } |
* } |
* } |
|
* |
|
* MatchingRuleAssertion ::= SEQUENCE { |
|
* matchingRule [1] MatchingRuleId OPTIONAL, |
|
* type [2] AttributeDescription OPTIONAL, |
|
* matchValue [3] AssertionValue, |
|
* dnAttributes [4] BOOLEAN DEFAULT FALSE |
|
* } |
|
* |
*/ |
*/ |
|
|
f = (Filter *) ch_malloc( sizeof(Filter) ); |
f = (Filter *) ch_malloc( sizeof(Filter) ); |
f->f_next = NULL; |
f->f_next = NULL; |
|
|
err = 0; |
err = LDAP_SUCCESS; |
*fstr = NULL; |
*fstr = NULL; |
f->f_choice = ber_peek_tag( ber, &len ); |
f->f_choice = ber_peek_tag( ber, &len ); |
|
|
switch ( f->f_choice ) { |
switch ( f->f_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "EQUALITY\n", 0, 0, 0 ); |
if ( (err = get_ava( ber, &f->f_ava )) == 0 ) { |
if ( (err = get_ava( ber, &f->f_ava )) == LDAP_SUCCESS ) { |
*fstr = ch_malloc(4 + strlen( f->f_avtype ) + |
*fstr = ch_malloc(4 + strlen( f->f_avtype ) + |
f->f_avvalue.bv_len); |
f->f_avvalue.bv_len); |
sprintf( *fstr, "(%s=%s)", f->f_avtype, |
sprintf( *fstr, "(%s=%s)", f->f_avtype, |
Line 71 get_filter( Connection *conn, BerElement
|
Line 80 get_filter( Connection *conn, BerElement
|
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "GE\n", 0, 0, 0 ); |
if ( (err = get_ava( ber, &f->f_ava )) == 0 ) { |
if ( (err = get_ava( ber, &f->f_ava )) == LDAP_SUCCESS ) { |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
f->f_avvalue.bv_len); |
f->f_avvalue.bv_len); |
sprintf( *fstr, "(%s>=%s)", f->f_avtype, |
sprintf( *fstr, "(%s>=%s)", f->f_avtype, |
Line 81 get_filter( Connection *conn, BerElement
|
Line 90 get_filter( Connection *conn, BerElement
|
|
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "LE\n", 0, 0, 0 ); |
if ( (err = get_ava( ber, &f->f_ava )) == 0 ) { |
if ( (err = get_ava( ber, &f->f_ava )) == LDAP_SUCCESS ) { |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
f->f_avvalue.bv_len); |
f->f_avvalue.bv_len); |
sprintf( *fstr, "(%s<=%s)", f->f_avtype, |
sprintf( *fstr, "(%s<=%s)", f->f_avtype, |
Line 92 get_filter( Connection *conn, BerElement
|
Line 101 get_filter( Connection *conn, BerElement
|
case LDAP_FILTER_PRESENT: |
case LDAP_FILTER_PRESENT: |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "PRESENT\n", 0, 0, 0 ); |
if ( ber_scanf( ber, "a", &f->f_type ) == LBER_ERROR ) { |
if ( ber_scanf( ber, "a", &f->f_type ) == LBER_ERROR ) { |
err = LDAP_PROTOCOL_ERROR; |
err = -1; |
} else { |
} else { |
err = LDAP_SUCCESS; |
err = LDAP_SUCCESS; |
attr_normalize( f->f_type ); |
attr_normalize( f->f_type ); |
Line 103 get_filter( Connection *conn, BerElement
|
Line 112 get_filter( Connection *conn, BerElement
|
|
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "APPROX\n", 0, 0, 0 ); |
if ( (err = get_ava( ber, &f->f_ava )) == 0 ) { |
if ( (err = get_ava( ber, &f->f_ava )) == LDAP_SUCCESS ) { |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
*fstr = ch_malloc(5 + strlen( f->f_avtype ) + |
f->f_avvalue.bv_len); |
f->f_avvalue.bv_len); |
sprintf( *fstr, "(%s~=%s)", f->f_avtype, |
sprintf( *fstr, "(%s~=%s)", f->f_avtype, |
Line 114 get_filter( Connection *conn, BerElement
|
Line 123 get_filter( Connection *conn, BerElement
|
case LDAP_FILTER_AND: |
case LDAP_FILTER_AND: |
Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "AND\n", 0, 0, 0 ); |
if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp )) |
if ( (err = get_filter_list( conn, ber, &f->f_and, &ftmp )) |
== 0 ) { |
== LDAP_SUCCESS ) { |
if (ftmp == NULL) ftmp = ch_strdup(""); |
if (ftmp == NULL) ftmp = ch_strdup(""); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
sprintf( *fstr, "(&%s)", ftmp ); |
sprintf( *fstr, "(&%s)", ftmp ); |
Line 125 get_filter( Connection *conn, BerElement
|
Line 134 get_filter( Connection *conn, BerElement
|
case LDAP_FILTER_OR: |
case LDAP_FILTER_OR: |
Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "OR\n", 0, 0, 0 ); |
if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp )) |
if ( (err = get_filter_list( conn, ber, &f->f_or, &ftmp )) |
== 0 ) { |
== LDAP_SUCCESS ) { |
if (ftmp == NULL) ftmp = ch_strdup(""); |
if (ftmp == NULL) ftmp = ch_strdup(""); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
sprintf( *fstr, "(|%s)", ftmp ); |
sprintf( *fstr, "(|%s)", ftmp ); |
Line 136 get_filter( Connection *conn, BerElement
|
Line 145 get_filter( Connection *conn, BerElement
|
case LDAP_FILTER_NOT: |
case LDAP_FILTER_NOT: |
Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "NOT\n", 0, 0, 0 ); |
(void) ber_skip_tag( ber, &len ); |
(void) ber_skip_tag( ber, &len ); |
if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == 0 ) { |
if ( (err = get_filter( conn, ber, &f->f_not, &ftmp )) == LDAP_SUCCESS ) { |
if (ftmp == NULL) ftmp = ch_strdup(""); |
if (ftmp == NULL) ftmp = ch_strdup(""); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
*fstr = ch_malloc( 4 + strlen( ftmp ) ); |
sprintf( *fstr, "(!%s)", ftmp ); |
sprintf( *fstr, "(!%s)", ftmp ); |
Line 144 get_filter( Connection *conn, BerElement
|
Line 153 get_filter( Connection *conn, BerElement
|
} |
} |
break; |
break; |
|
|
|
case LBER_DEFAULT: |
|
Debug( LDAP_DEBUG_ANY, "decoding filter error\n", |
|
0, 0, 0 ); |
|
err = -1; |
|
break; |
|
|
default: |
default: |
Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n", |
Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n", |
f->f_choice, 0, 0 ); |
f->f_choice, 0, 0 ); |
Line 151 get_filter( Connection *conn, BerElement
|
Line 166 get_filter( Connection *conn, BerElement
|
break; |
break; |
} |
} |
|
|
if ( err != 0 ) { |
if ( err != LDAP_SUCCESS ) { |
free( (char *) f ); |
free( (char *) f ); |
if ( *fstr != NULL ) { |
if ( *fstr != NULL ) { |
free( *fstr ); |
free( *fstr ); |
Line 178 get_filter_list( Connection *conn, BerEl
|
Line 193 get_filter_list( Connection *conn, BerEl
|
*fstr = NULL; |
*fstr = NULL; |
new = f; |
new = f; |
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; |
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) { |
tag = ber_next_element( ber, &len, last ) ) |
if ( (err = get_filter( conn, ber, new, &ftmp )) != 0 ) |
{ |
|
if ( (err = get_filter( conn, ber, new, &ftmp )) != LDAP_SUCCESS ) |
return( err ); |
return( err ); |
if ( *fstr == NULL ) { |
if ( *fstr == NULL ) { |
*fstr = ftmp; |
*fstr = ftmp; |
Line 194 get_filter_list( Connection *conn, BerEl
|
Line 210 get_filter_list( Connection *conn, BerEl
|
*new = NULL; |
*new = NULL; |
|
|
Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_filter_list\n", 0, 0, 0 ); |
return( 0 ); |
return( LDAP_SUCCESS ); |
} |
} |
|
|
static int |
static int |
Line 214 get_substring_filter(
|
Line 230 get_substring_filter(
|
Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_substring_filter\n", 0, 0, 0 ); |
|
|
if ( ber_scanf( ber, "{a" /*}*/, &f->f_sub_type ) == LBER_ERROR ) { |
if ( ber_scanf( ber, "{a" /*}*/, &f->f_sub_type ) == LBER_ERROR ) { |
return( LDAP_PROTOCOL_ERROR ); |
return( -1 ); |
} |
} |
attr_normalize( f->f_sub_type ); |
attr_normalize( f->f_sub_type ); |
syntax = attr_syntax( f->f_sub_type ); |
syntax = attr_syntax( f->f_sub_type ); |
Line 225 get_substring_filter(
|
Line 241 get_substring_filter(
|
*fstr = ch_malloc( strlen( f->f_sub_type ) + 3 ); |
*fstr = ch_malloc( strlen( f->f_sub_type ) + 3 ); |
sprintf( *fstr, "(%s=", f->f_sub_type ); |
sprintf( *fstr, "(%s=", f->f_sub_type ); |
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; |
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT; |
tag = ber_next_element( ber, &len, last ) ) { |
tag = ber_next_element( ber, &len, last ) ) |
rc = ber_scanf( ber, "a", &val ); |
{ |
|
rc = ber_scanf( ber, "a", &val ); |
if ( rc == LBER_ERROR ) { |
if ( rc == LBER_ERROR ) { |
return( LDAP_PROTOCOL_ERROR ); |
return( -1 ); |
} |
} |
if ( val == NULL || *val == '\0' ) { |
if ( val == NULL || *val == '\0' ) { |
if ( val != NULL ) { |
if ( val != NULL ) { |
Line 284 get_substring_filter(
|
Line 301 get_substring_filter(
|
strcat( *fstr, ")" ); |
strcat( *fstr, ")" ); |
|
|
Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "end get_substring_filter\n", 0, 0, 0 ); |
return( 0 ); |
return( LDAP_SUCCESS ); |
} |
} |
|
|
void |
void |