]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/test.c
import fix to ITS#4669
[openldap] / libraries / libldap / test.c
index 642e804dc8cf8196e00ac22a2a8f1c5858bd600b..88060893121c4fd5a198f3dc6072e40a618d2585 100644 (file)
@@ -1,7 +1,16 @@
 /* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
+ *
+ * Copyright 1998-2006 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * <http://www.OpenLDAP.org/license.html>.
  */
 
 #include "portable.h"
@@ -50,7 +59,7 @@ static char *dnsuffix;
 static char *
 get_line( char *line, int len, FILE *fp, const char *prompt )
 {
-       printf(prompt);
+       fputs(prompt, stdout);
 
        if ( fgets( line, len, fp ) == NULL )
                return( NULL );
@@ -59,7 +68,6 @@ get_line( char *line, int len, FILE *fp, const char *prompt )
 
        return( line );
 }
-#endif
 
 static char **
 get_list( const char *prompt )
@@ -161,7 +169,7 @@ get_modlist(
 {
        static char     buf[256];
        int             num;
-       LDAPMod         tmp;
+       LDAPMod         tmp = { 0 };
        LDAPMod         **result;
        struct berval   **bvals;
 
@@ -197,6 +205,10 @@ get_modlist(
                                    6 ) == 0 ) {
                                        if ( file_read( tmp.mod_values[i] + 6,
                                            bvals[i] ) < 0 ) {
+                                               free( bvals );
+                                               for ( i = 0; i<num; i++ )
+                                                       free( result[ i ] );
+                                               free( result );
                                                return( NULL );
                                        }
                                } else {
@@ -579,7 +591,7 @@ main( int argc, char **argv )
                        get_line( dn, sizeof(dn), stdin, "searchbase? " );
                        strcat( dn, dnsuffix );
                        get_line( line, sizeof(line), stdin,
-                           "scope (0=Base, 1=One Level, 2=Subtree)? " );
+                           "scope (0=baseObject, 1=oneLevel, 2=subtree, 3=children)? " );
                        scope = atoi( line );
                        get_line( filter, sizeof(filter), stdin,
                            "search filter (e.g. sn=jones)? " );
@@ -628,9 +640,14 @@ main( int argc, char **argv )
                                    printf( " <%s>", ludp->lud_attrs[ i ] );
                                }
                            }
-                           printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
-                               "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
-                               ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
+                           printf( "\n\t scope: %s\n",
+                                       ludp->lud_scope == LDAP_SCOPE_BASE ? "baseObject"
+                                       : ludp->lud_scope == LDAP_SCOPE_ONELEVEL ? "oneLevel"
+                                       : ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "subtree"
+#ifdef LDAP_SCOPE_SUBORDINATE
+                                       : ludp->lud_scope == LDAP_SCOPE_SUBORDINATE ? "children"
+#endif
+                                       : "**invalid**" );
                            printf( "\tfilter: <%s>\n", ludp->lud_filter );
                            ldap_free_urldesc( ludp );
                        }