]> git.sur5r.net Git - openldap/blobdiff - libraries/libavl/testavl.c
Add security checks to root DSE searches.
[openldap] / libraries / libavl / testavl.c
index 60af40362ca561eadde9138284f0541c7f116568..de948d8bcd48193942f8e7bffeaa6cd9d3867b33 100644 (file)
@@ -1,13 +1,19 @@
 /* testavl.c - Test Tim Howes AVL code */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
 
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>
 
+#include <ac/stdlib.h>
 #include <ac/string.h>
-#include <sys/types.h>
 
+#define AVL_INTERNAL
+#define AVL_NONREENTRANT 
 #include "avl.h"
 
 static void ravl_print LDAP_P(( Avlnode *root, int depth ));
@@ -16,7 +22,7 @@ static void myprint LDAP_P(( Avlnode *root ));
 int
 main( int argc, char **argv )
 {
-       Avlnode *tree = NULLAVL;
+       Avlnode *tree = NULL;
        char    command[ 10 ];
        char    name[ 80 ];
        char    *p;
@@ -26,22 +32,27 @@ main( int argc, char **argv )
                switch( *command ) {
                case 'n':       /* new tree */
                        ( void ) avl_free( tree, (AVL_FREE) free );
-                       tree = NULLAVL;
+                       tree = NULL;
                        break;
                case 'p':       /* print */
                        ( void ) myprint( tree );
                        break;
                case 't':       /* traverse with first, next */
+#ifdef AVL_NONREENTRANT
                        printf( "***\n" );
                        for ( p = (char * ) avl_getfirst( tree );
-                           p != NULL; p = (char *) avl_getnext( /* tree, p */ ) )
+                           p != NULL;
+                               p = (char *) avl_getnext())
                                printf( "%s\n", p );
                        printf( "***\n" );
+#else
+                       printf( "*** reentrant interface not implemented ***" );
+#endif
                        break;
                case 'f':       /* find */
                        printf( "data? " );
                        if ( fgets( name, sizeof( name ), stdin ) == NULL )
-                               exit( 0 );
+                               exit( EXIT_SUCCESS );
                        name[ strlen( name ) - 1 ] = '\0';
                        if ( (p = (char *) avl_find( tree, name, (AVL_CMP) strcmp ))
                            == NULL )
@@ -52,7 +63,7 @@ main( int argc, char **argv )
                case 'i':       /* insert */
                        printf( "data? " );
                        if ( fgets( name, sizeof( name ), stdin ) == NULL )
-                               exit( 0 );
+                               exit( EXIT_SUCCESS );
                        name[ strlen( name ) - 1 ] = '\0';
                        if ( avl_insert( &tree, strdup( name ), (AVL_CMP) strcmp, 
                            avl_dup_error ) != 0 )
@@ -61,13 +72,13 @@ main( int argc, char **argv )
                case 'd':       /* delete */
                        printf( "data? " );
                        if ( fgets( name, sizeof( name ), stdin ) == NULL )
-                               exit( 0 );
+                               exit( EXIT_SUCCESS );
                        name[ strlen( name ) - 1 ] = '\0';
                        if ( avl_delete( &tree, name, (AVL_CMP) strcmp ) == NULL )
                                printf( "\nNot found!\n" );
                        break;
                case 'q':       /* quit */
-                       exit( 0 );
+                       exit( EXIT_SUCCESS );
                        break;
                case '\n':
                        break;