version 1.3.10.1, 1998/10/20 23:24:28
|
version 1.4.2.3, 1998/11/16 23:24:28
|
Line 3
|
Line 3
|
#include "portable.h" |
#include "portable.h" |
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <string.h> |
|
#include <sys/types.h> |
|
#include <sys/socket.h> |
|
#include "slap.h" |
|
|
|
static int get_filter_list(); |
#include <ac/socket.h> |
static int get_substring_filter(); |
#include <ac/string.h> |
|
|
|
#include "slap.h" |
|
|
extern int get_ava(); |
static int get_filter_list(Connection *conn, BerElement *ber, Filter **f, char **fstr); |
extern char *ch_malloc(); |
static int get_substring_filter(Connection *conn, BerElement *ber, Filter *f, char **fstr); |
extern char *ch_realloc(); |
|
|
|
int |
int |
get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) |
get_filter( Connection *conn, BerElement *ber, Filter **filt, char **fstr ) |
Line 56 get_filter( Connection *conn, BerElement
|
Line 53 get_filter( Connection *conn, BerElement
|
err = 0; |
err = 0; |
*fstr = NULL; |
*fstr = NULL; |
f->f_choice = ber_peek_tag( ber, &len ); |
f->f_choice = ber_peek_tag( ber, &len ); |
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
if ( conn->c_version == 30 ) { |
if ( conn->c_version == 30 ) { |
switch ( f->f_choice ) { |
switch ( f->f_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
Line 167 get_filter( Connection *conn, BerElement
|
Line 164 get_filter( Connection *conn, BerElement
|
break; |
break; |
|
|
default: |
default: |
Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice, |
Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n", |
0, 0 ); |
f->f_choice, 0, 0 ); |
err = LDAP_PROTOCOL_ERROR; |
err = LDAP_PROTOCOL_ERROR; |
break; |
break; |
} |
} |
Line 194 get_filter_list( Connection *conn, BerEl
|
Line 191 get_filter_list( Connection *conn, BerEl
|
|
|
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); |
Debug( LDAP_DEBUG_FILTER, "begin get_filter_list\n", 0, 0, 0 ); |
|
|
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
if ( conn->c_version == 30 ) { |
if ( conn->c_version == 30 ) { |
(void) ber_skip_tag( ber, &len ); |
(void) ber_skip_tag( ber, &len ); |
} |
} |
Line 235 get_substring_filter(
|
Line 232 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 ); |
|
|
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
if ( conn->c_version == 30 ) { |
if ( conn->c_version == 30 ) { |
(void) ber_skip_tag( ber, &len ); |
(void) ber_skip_tag( ber, &len ); |
} |
} |
Line 253 get_substring_filter(
|
Line 250 get_substring_filter(
|
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 ) ) { |
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
if ( conn->c_version == 30 ) { |
if ( conn->c_version == 30 ) { |
rc = ber_scanf( ber, "{a}", &val ); |
rc = ber_scanf( ber, "{a}", &val ); |
} else |
} else |
Line 271 get_substring_filter(
|
Line 268 get_substring_filter(
|
value_normalize( val, syntax ); |
value_normalize( val, syntax ); |
|
|
switch ( tag ) { |
switch ( tag ) { |
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
case LDAP_SUBSTRING_INITIAL_30: |
case LDAP_SUBSTRING_INITIAL_30: |
#endif |
#endif |
case LDAP_SUBSTRING_INITIAL: |
case LDAP_SUBSTRING_INITIAL: |
Line 285 get_substring_filter(
|
Line 282 get_substring_filter(
|
strcat( *fstr, val ); |
strcat( *fstr, val ); |
break; |
break; |
|
|
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
case LDAP_SUBSTRING_ANY_30: |
case LDAP_SUBSTRING_ANY_30: |
#endif |
#endif |
case LDAP_SUBSTRING_ANY: |
case LDAP_SUBSTRING_ANY: |
Line 297 get_substring_filter(
|
Line 294 get_substring_filter(
|
strcat( *fstr, val ); |
strcat( *fstr, val ); |
break; |
break; |
|
|
#ifdef COMPAT30 |
#ifdef LDAP_COMPAT30 |
case LDAP_SUBSTRING_FINAL_30: |
case LDAP_SUBSTRING_FINAL_30: |
#endif |
#endif |
case LDAP_SUBSTRING_FINAL: |
case LDAP_SUBSTRING_FINAL: |
Line 374 filter_free( Filter *f )
|
Line 371 filter_free( Filter *f )
|
break; |
break; |
|
|
default: |
default: |
Debug( LDAP_DEBUG_ANY, "unknown filter type %d\n", f->f_choice, |
Debug( LDAP_DEBUG_ANY, "unknown filter type %lu\n", |
0, 0 ); |
f->f_choice, 0, 0 ); |
break; |
break; |
} |
} |
free( f ); |
free( f ); |
Line 390 filter_print( Filter *f )
|
Line 387 filter_print( Filter *f )
|
Filter *p; |
Filter *p; |
|
|
if ( f == NULL ) { |
if ( f == NULL ) { |
printf( "NULL" ); |
fprintf( stderr, "NULL" ); |
} |
} |
|
|
switch ( f->f_choice ) { |
switch ( f->f_choice ) { |
case LDAP_FILTER_EQUALITY: |
case LDAP_FILTER_EQUALITY: |
printf( "(%s=%s)", f->f_ava.ava_type, |
fprintf( stderr, "(%s=%s)", f->f_ava.ava_type, |
f->f_ava.ava_value.bv_val ); |
f->f_ava.ava_value.bv_val ); |
break; |
break; |
|
|
case LDAP_FILTER_GE: |
case LDAP_FILTER_GE: |
printf( "(%s>=%s)", f->f_ava.ava_type, |
fprintf( stderr, "(%s>=%s)", f->f_ava.ava_type, |
f->f_ava.ava_value.bv_val ); |
f->f_ava.ava_value.bv_val ); |
break; |
break; |
|
|
case LDAP_FILTER_LE: |
case LDAP_FILTER_LE: |
printf( "(%s<=%s)", f->f_ava.ava_type, |
fprintf( stderr, "(%s<=%s)", f->f_ava.ava_type, |
f->f_ava.ava_value.bv_val ); |
f->f_ava.ava_value.bv_val ); |
break; |
break; |
|
|
case LDAP_FILTER_APPROX: |
case LDAP_FILTER_APPROX: |
printf( "(%s~=%s)", f->f_ava.ava_type, |
fprintf( stderr, "(%s~=%s)", f->f_ava.ava_type, |
f->f_ava.ava_value.bv_val ); |
f->f_ava.ava_value.bv_val ); |
break; |
break; |
|
|
case LDAP_FILTER_SUBSTRINGS: |
case LDAP_FILTER_SUBSTRINGS: |
printf( "(%s=", f->f_sub_type ); |
fprintf( stderr, "(%s=", f->f_sub_type ); |
if ( f->f_sub_initial != NULL ) { |
if ( f->f_sub_initial != NULL ) { |
printf( "%s", f->f_sub_initial ); |
fprintf( stderr, "%s", f->f_sub_initial ); |
} |
} |
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++ ) { |
printf( "*%s", f->f_sub_any[i] ); |
fprintf( stderr, "*%s", f->f_sub_any[i] ); |
} |
} |
} |
} |
charray_free( f->f_sub_any ); |
charray_free( f->f_sub_any ); |
if ( f->f_sub_final != NULL ) { |
if ( f->f_sub_final != NULL ) { |
printf( "*%s", f->f_sub_final ); |
fprintf( stderr, "*%s", f->f_sub_final ); |
} |
} |
break; |
break; |
|
|
case LDAP_FILTER_PRESENT: |
case LDAP_FILTER_PRESENT: |
printf( "%s=*", f->f_type ); |
fprintf( stderr, "%s=*", f->f_type ); |
break; |
break; |
|
|
case LDAP_FILTER_AND: |
case LDAP_FILTER_AND: |
case LDAP_FILTER_OR: |
case LDAP_FILTER_OR: |
case LDAP_FILTER_NOT: |
case LDAP_FILTER_NOT: |
printf( "(%c", f->f_choice == LDAP_FILTER_AND ? '&' : |
fprintf( stderr, "(%c", f->f_choice == LDAP_FILTER_AND ? '&' : |
f->f_choice == LDAP_FILTER_OR ? '|' : '!' ); |
f->f_choice == LDAP_FILTER_OR ? '|' : '!' ); |
for ( p = f->f_list; p != NULL; p = p->f_next ) { |
for ( p = f->f_list; p != NULL; p = p->f_next ) { |
filter_print( p ); |
filter_print( p ); |
} |
} |
printf( ")" ); |
fprintf( stderr, ")" ); |
break; |
break; |
|
|
default: |
default: |
printf( "unknown type %d", f->f_choice ); |
fprintf( stderr, "unknown type %lu", f->f_choice ); |
break; |
break; |
} |
} |
} |
} |