/* testavl.c - Test Tim Howes AVL code */
+/* $OpenLDAP$ */
+/*
+ * Copyright 1998-2002 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>
+#define AVL_INTERNAL
#define AVL_NONREENTRANT
#include "avl.h"
int
main( int argc, char **argv )
{
- Avlnode *tree = NULLAVL;
+ Avlnode *tree = NULL;
char command[ 10 ];
char name[ 80 ];
char *p;
switch( *command ) {
case 'n': /* new tree */
( void ) avl_free( tree, (AVL_FREE) free );
- tree = NULLAVL;
+ tree = NULL;
break;
case 'p': /* print */
( void ) myprint( tree );
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 )
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 )
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;