2002-07-19 03:00:24 +04:00
/*
* Unix SMB / CIFS implementation .
* Generic Abstract Data Types
2005-09-03 20:38:51 +04:00
* Copyright ( C ) Gerald Carter 2002 - 2005.
2002-07-19 03:00:24 +04:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2002-07-19 03:00:24 +04:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2002-07-19 03:00:24 +04:00
*/
# ifndef ADT_TREE_H
# define ADT_TREE_H
2005-02-23 19:36:44 +03:00
/* data structure used to build the tree */
2002-07-19 03:00:24 +04:00
typedef struct _tree_node {
struct _tree_node * parent ;
struct _tree_node * * children ;
int num_children ;
char * key ;
void * data_p ;
} TREE_NODE ;
typedef struct _tree_root {
TREE_NODE * root ;
2005-09-03 20:38:51 +04:00
/* not used currently (is it needed?) */
2002-07-19 03:00:24 +04:00
int ( * compare ) ( void * x , void * y ) ;
} SORTED_TREE ;
2005-02-23 19:36:44 +03:00
/*
* API
*/
2005-09-03 20:38:51 +04:00
/* create a new tree, talloc_free() to throw it away */
SORTED_TREE * pathtree_init ( void * data_p , int ( cmp_fn ) ( void * , void * ) ) ;
2005-02-23 19:36:44 +03:00
/* add a new path component */
2007-10-19 04:40:25 +04:00
bool pathtree_add ( SORTED_TREE * tree , const char * path , void * data_p ) ;
2005-02-23 19:36:44 +03:00
/* search path */
void * pathtree_find ( SORTED_TREE * tree , char * key ) ;
/* debug (print) functions */
void pathtree_print_keys ( SORTED_TREE * tree , int debug ) ;
2002-07-19 03:00:24 +04:00
# endif