]> git.sur5r.net Git - openldap/commitdiff
Fix stupid bug in last commit
authorKurt Zeilenga <kurt@openldap.org>
Wed, 2 Jan 2002 18:16:09 +0000 (18:16 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 2 Jan 2002 18:16:09 +0000 (18:16 +0000)
libraries/libldap/filter.c
libraries/libldap/ftest.c

index a945cd71e49b8c7bd8d5f6215c1f1c75b4f5d2eb..960327de282f4950b933d42ae155c150b22cdd3e 100644 (file)
@@ -201,7 +201,7 @@ ldap_pvt_find_wildcard( const char *s )
                }
        }
 
-       return NULL;
+       return s;
 }
 
 /* unescape filter value */
@@ -222,7 +222,6 @@ ldap_pvt_filter_value_unescape( char *fval )
                        if ( fval[v] == '\0' ) {
                                /* escape at end of string */
                                return -1;
-
                        }
 
                        if (( v1 = hex2value( fval[v] )) >= 0 ) {
@@ -350,9 +349,9 @@ ldap_int_put_filter( BerElement *ber, char *str )
                                Debug( LDAP_DEBUG_TRACE, "put_filter: AND\n",
                                    0, 0, 0 );
 
-                               if ( (str = put_complex_filter( ber, str,
-                                   LDAP_FILTER_AND, 0 )) == NULL )
-                                       return( -1 );
+                               str = put_complex_filter( ber, str,
+                                   LDAP_FILTER_AND, 0 );
+                               if( str == NULL ) return( -1 );
 
                                parens--;
                                break;
@@ -361,9 +360,9 @@ ldap_int_put_filter( BerElement *ber, char *str )
                                Debug( LDAP_DEBUG_TRACE, "put_filter: OR\n",
                                    0, 0, 0 );
 
-                               if ( (str = put_complex_filter( ber, str,
-                                   LDAP_FILTER_OR, 0 )) == NULL )
-                                       return( -1 );
+                               str = put_complex_filter( ber, str,
+                                   LDAP_FILTER_OR, 0 );
+                               if( str == NULL ) return( -1 );
 
                                parens--;
                                break;
@@ -372,9 +371,9 @@ ldap_int_put_filter( BerElement *ber, char *str )
                                Debug( LDAP_DEBUG_TRACE, "put_filter: NOT\n",
                                    0, 0, 0 );
 
-                               if ( (str = put_complex_filter( ber, str,
-                                   LDAP_FILTER_NOT, 1 )) == NULL )
-                                       return( -1 );
+                               str = put_complex_filter( ber, str,
+                                   LDAP_FILTER_NOT, 0 );
+                               if( str == NULL ) return( -1 );
 
                                parens--;
                                break;
@@ -597,7 +596,7 @@ put_simple_filter(
                                ber_slen_t len = ldap_pvt_filter_value_unescape( value );
 
                                if( len >= 0 ) {
-                                       rc = ber_printf( ber, "totbN}",
+                                       rc = ber_printf( ber, /*"{"*/ "totbN}",
                                                LDAP_FILTER_EXT_VALUE, value, len,
                                                LDAP_FILTER_EXT_DNATTRS, dn != NULL);
                                } else {
@@ -611,7 +610,6 @@ put_simple_filter(
                {
                        char *nextstar = ldap_pvt_find_wildcard( value );
                        if ( nextstar == NULL ) {
-                               rc = -1;
                                goto done;
                        } else if ( *nextstar == '\0' ) {
                                ftype = LDAP_FILTER_EQUALITY;
@@ -636,9 +634,8 @@ put_simple_filter(
                }
        }
 
-       if( rc != -1 ) rc = 0;
-
 done:
+       if( rc != -1 ) rc = 0;
        LDAP_FREE( str );
        return rc;
 }
@@ -687,7 +684,7 @@ put_substring_filter( BerElement *ber, char *type, char *val )
        }
 
        if ( ber_printf( ber, /*"{{"*/ "N}N}" ) == -1 )
-               return( -1 );
+               return -1;
 
        return 0;
-}
\ No newline at end of file
+}
index 22f7646e32d51fb37f0397253efc7a4f72d227ca..6f9a227a18f503febf6aaf52dc594c0bdd0f4fe0 100644 (file)
@@ -27,7 +27,7 @@ static int filter2ber( char *filter );
 int usage()
 {
        fprintf( stderr, "usage:\n"
-               "\tftest [-d n] filter" );
+               "\tftest [-d n] filter\n" );
        return EXIT_FAILURE;
 }
 
@@ -90,8 +90,8 @@ static int filter2ber( char *filter )
        }
 
        rc = ldap_int_put_filter( ber, filter );
-       if( rc ) {
-               perror( "ber_flatten" );
+       if( rc < 0 ) {
+               fprintf( stderr, "Filter error!\n");
                return EXIT_FAILURE;
        }
 
@@ -101,6 +101,7 @@ static int filter2ber( char *filter )
                return EXIT_FAILURE;
        }
 
+       printf( "BER encoding (len=%ld):\n", (long) bv->bv_len );
        ber_bprint( bv->bv_val, bv->bv_len );
 
        ber_free( ber, 0 );