2 * Copyright 1998,1999 The OpenLDAP Foundation, Redwood City, California, USA
5 * Redistribution and use in source and binary forms are permitted only
6 * as authorized by the OpenLDAP Public License. A copy of this
7 * license is available at http://www.OpenLDAP.org/license.html or
8 * in file LICENSE in the top-level directory of the distribution.
11 * Copyright (c) 1993 Regents of the University of Michigan.
12 * All rights reserved.
14 * Redistribution and use in source and binary forms are permitted
15 * provided that this notice is preserved and that due credit is given
16 * to the University of Michigan at Ann Arbor. The name of the University
17 * may not be used to endorse or promote products derived from this
18 * software without specific prior written permission. This software
19 * is provided ``as is'' without express or implied warranty.
21 /* avl.h - avl tree definitions */
27 #include <ldap_cdefs.h>
30 * this structure represents a generic avl tree node.
35 typedef struct avlnode {
38 struct avlnode *avl_left;
39 struct avlnode *avl_right;
42 #define NULLAVL ((Avlnode *) NULL)
44 /* balance factor values */
50 #define avl_getone(x) ((x) == 0 ? 0 : (x)->avl_data)
51 #define avl_onenode(x) ((x) == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
53 /* looks like this function pointer is not used consistently */
54 /* typedef int (*IFP)LDAP_P((caddr_t, caddr_t)); */
58 avl_free LDAP_P(( Avlnode *root, IFP dfree ));
61 avl_insert LDAP_P((Avlnode **, caddr_t, IFP, IFP));
64 avl_delete LDAP_P((Avlnode **, caddr_t, IFP));
67 avl_find LDAP_P((Avlnode *, caddr_t, IFP));
70 avl_find_lin LDAP_P((Avlnode *, caddr_t, IFP));
73 avl_getfirst LDAP_P((Avlnode *));
76 /* ??? avl.c does not provide this version ??? */
78 avl_getnext LDAP_P((Avlnode *, caddr_t ));
81 avl_getnext LDAP_P((void));
85 avl_dup_error LDAP_P((void));
88 avl_dup_ok LDAP_P((void));
91 avl_apply LDAP_P((Avlnode *, IFP, caddr_t, int, int));
94 avl_prefixapply LDAP_P((Avlnode *, caddr_t, IFP, caddr_t, IFP, caddr_t, int));
96 /* apply traversal types */
97 #define AVL_PREORDER 1
99 #define AVL_POSTORDER 3
100 /* what apply returns if it ran out of nodes */
101 #define AVL_NOMORE (-6)