1 /* $Id$
2  *  Provides functions to operate with linked binary tree.
3  *
4  * This program text was created by Paul Vixie using examples from the book:
5  * "Algorithms & Data Structures," Niklaus Wirth, Prentice-Hall, 1986, ISBN
6  * 0-13-022005-1.
7  *
8  *  Latest version may be foind on http://husky.sourceforge.net
9  *
10  *
11  * HUSKYLIB: common defines, types and functions for HUSKY
12  *
13  * This is part of The HUSKY Fidonet Software project:
14  * see http://husky.sourceforge.net for details
15  *
16  *
17  * HUSKYLIB is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU Lesser General Public
19  * License as published by the Free Software Foundation; either
20  * version 2 of the License, or (at your option) any later version.
21  *
22  * HUSKYLIB is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
25  * General Public License for more details.
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; see file COPYING. If not, write to the
29  * Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  *
31  * See also http://www.gnu.org, license may be found here.
32  */
33 
34 #ifndef	HUSKY_TREE_H
35 #define	HUSKY_TREE_H
36 
37 /* huskylib: compiler.h */
38 #include "compiler.h"
39 
40 /* huskylib headers */
41 #include "huskyext.h"
42 
43 /***  Declarations & defines  ***********************************************/
44 
45 typedef struct  tree_s
46 {
47     struct  tree_s  *tree_l, *tree_r;
48     short   tree_b;
49     char*   tree_p;
50     char    need_b;
51 }
52 tree;
53 
54 HUSKYEXT void  tree_init(tree **ppr_tree, char need_balance);
55 
56 HUSKYEXT char* tree_srch(tree **ppr_tree, int (*pfi_compare)(char *, char *),char * pc_user);
57 
58 HUSKYEXT int   tree_add(tree **ppr_tree, int (*pfi_compare)(char *, char *), char *pc_user, int (*pfi_delete)(char *));
59 
60 HUSKYEXT int   tree_delete(tree **ppr_p, int (*pfi_compare)(char *, char *), char *pc_user, int (*pfi_uar)(char *));
61 
62 HUSKYEXT int   tree_trav(tree **ppr_tree, int (*pfi_uar)(char *));
63 
64 HUSKYEXT void  tree_mung(tree **ppr_tree, int (*pfi_uar)(char *));
65 
66 HUSKYEXT unsigned long tree_count(tree **ppr_tree);
67 
68 HUSKYEXT int tree_srchall(tree **ppr_tree, int (*pfi_compare)(char *, char *),char * pc_user);
69 
70 #endif
71