]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/test.c
Add lber_log_print support to libldap.
[openldap] / libraries / libldap / test.c
index 66e86efb85d0f159be6b70819956226299f71297..23088a116620cb41626733ebcf55085a7bc48a1b 100644 (file)
@@ -1,3 +1,8 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
 #include "portable.h"
 
 #include <stdio.h>
@@ -295,9 +300,11 @@ main( int argc, char **argv )
                case 'd':
 #ifdef LDAP_DEBUG
                        ldap_debug = atoi( optarg );
+#ifdef LBER_DEBUG
                        if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
                                lber_debug = ldap_debug;
                        }
+#endif
 #else
                        printf( "Compile with -DLDAP_DEBUG for debugging\n" );
 #endif
@@ -477,9 +484,11 @@ main( int argc, char **argv )
 #ifdef LDAP_DEBUG
                        getline( line, sizeof(line), stdin, "debug level? " );
                        ldap_debug = atoi( line );
+#ifdef LBER_DEBUG
                        if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
                                lber_debug = ldap_debug;
                        }
+#endif
 #else
                        printf( "Compile with -DLDAP_DEBUG for debugging\n" );
 #endif
@@ -905,14 +914,14 @@ print_ldap_result( LDAP *ld, LDAPMessage *lm, char *s )
 static void
 print_search_entry( LDAP *ld, LDAPMessage *res )
 {
-       BerElement      *ber;
-       char            *a, *dn, *ufn;
-       struct berval   **vals;
-       int             i;
        LDAPMessage     *e;
 
        for ( e = ldap_first_entry( ld, res ); e != NULLMSG;
-           e = ldap_next_entry( ld, e ) ) {
+           e = ldap_next_entry( ld, e ) )
+       {
+               BerElement      *ber = NULL;
+               char *a, *dn, *ufn;
+
                if ( e->lm_msgtype == LDAP_RES_SEARCH_RESULT )
                        break;
 
@@ -926,12 +935,16 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
                free( ufn );
 
                for ( a = ldap_first_attribute( ld, e, &ber ); a != NULL;
-                   a = ldap_next_attribute( ld, e, ber ) ) {
+                   a = ldap_next_attribute( ld, e, ber ) )
+               {
+                       struct berval   **vals;
+
                        printf( "\t\tATTR: %s\n", a );
                        if ( (vals = ldap_get_values_len( ld, e, a ))
                            == NULL ) {
                                printf( "\t\t\t(no values)\n" );
                        } else {
+                               int i;
                                for ( i = 0; vals[i] != NULL; i++ ) {
                                        int     j, nonascii;
 
@@ -956,6 +969,10 @@ print_search_entry( LDAP *ld, LDAPMessage *res )
                                ber_bvecfree( vals );
                        }
                }
+
+               if(ber != NULL) {
+                       ber_free( ber, 0 );
+               }
        }
 
        if ( res->lm_msgtype == LDAP_RES_SEARCH_RESULT