File rx/rx_tree.c

  $Revision: 1.21 $

Radix tree (rx). rx_tree.c - functions to operate on trees (creation/deletion/finding).
Status: NOT REVUED, TESTED, INCOMPLETE
Design and implementation by: Marek Bukowy

Included Files


Preprocessor definitions

#define RX_IMPL

Global Variable Lock

pthread_mutex_t Lock
Included from /home/shane/release/RIP/include/ca_defs.h
Visible in:  aa/aa.c
   ac/ac_persistence.c
   ac/access_control.c
   au/AU_util.c
   ca/ca_configFns.c
   ca/ca_initFn.c
   ca/ca_sanityCheck.c
   ca/ca_sourceLoader.c
   ca/ca_values.c
   co/constants.c
   df/defs.c
   er/er.c
   er/er_arrays.c
   er/er_macro.c
   er/er_paths.c
   er/er_print.c
   ip/ip.c
   ma/bitmask.c
   mm/mm.c
   nh/nh.c
   pa/gpg.c
   pa/spawn.c
   pc/pc_commands.c
   pc/protocol_config.c
   pm/pm_serials.c
   pm/protocol_mirror.c
   pr/properties.c
   pw/protocol_whois.c
   qc/mg_getopt.c
   qc/query_command.c
   qi/query_instructions.c
   rp/rp_convert.c
   rp/rp_load.c
   rp/rp_search.c
   rp/rp_tree.c
   rp/rp_update.c
   rx/rx_node.c
   rx/rx_print.c
   rx/rx_search.c
   rx/rx_tree.c
Used in: ca_get_adminIntElement()ca/ca_configFns.c
  ca_get_adminStrElement()ca/ca_configFns.c
  ca_get_boolean()ca/ca_configFns.c
  ca_get_dirlist()ca/ca_configFns.c
  ca_get_int()ca/ca_configFns.c
  ca_get_string()ca/ca_configFns.c
  ca_set_boolean()ca/ca_configFns.c
  ca_srchandle2Intelement()ca/ca_configFns.c
  ca_srchandle2Strelement()ca/ca_configFns.c

Global Function RX_tree_cre()

  creates a (top) tree for the space, fills out sql table of trees
  generates a tablename for a tree (if NONE)
  updates LL of trees

MT-note: locks/unlocks the forest (still to be done)
er_ret_t RX_tree_cre ( char* prefixstr, rx_fam_t fam_id, rx_mem_mt mem_mode, rx_subtree_mt subtrees, rx_tree_t** treestore )
char* prefixstr
prefix the tree will cover (string)
rx_fam_t fam_id
 
rx_mem_mt mem_mode
 
rx_subtree_mt subtrees
one of NONE, AUTO, HAND
rx_tree_t** treestore
 
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: ER_dbg_va()er/er.c
  IP_pref_b2_space()ip/ip.c
  IP_pref_t2b()ip/ip.c
  IP_sizebits()ip/ip.c
  TH_init_read_write_lockw(), UT_malloc_real(), fprintf(), strcpy()
Called by: AC_build()ac/access_control.c
  RP_tree_add()rp/rp_tree.c

Global Function RX_treecheck()

er_ret_t RX_treecheck ( rx_tree_t* tree, int datatoo, rx_treecheck_t* errorfound )
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: rx_check_walk_tree()rx/rx_tree.c

Global Function rx_check_walk_tree()

int rx_check_walk_tree ( rx_node_t* node, rx_node_t* parent_node, int nodecounter, rx_treecheck_t* checkstruct )
Calls: rx_check_walk_tree()rx/rx_tree.c
  fprintf(), g_list_length()
Called by: RX_treecheck()rx/rx_tree.c
  rx_check_walk_tree()rx/rx_tree.c

Global Function rx_delete_dataleaves()

  go down the tree and delete all nodes of the tree.

the function is called recursively with level increased it stops recursing when no child nodes are found or maxlevel is reached.
therefore the initial call must set level to 0.
the nodecounter increments at every node, and is the return value of the function. So start with 0 to get the number of nodes traversed.
ERROR HANDLING IS DIFFERENT HERE! Unlike other functions it is not the return value: The error code from the func function IF DEFINED (== not NULL ) goes to the variable pointed to by the last parameter.
XXX: nodecounter is ALWAYS passed as 0, so should probably be removed from calling parameter list, shane 2001-02-01
void rx_delete_dataleaves ( void* element_data, void* result_ptr )
Calls: ER_dbg_va()er/er.c
  UT_free_real()
Used in: rx_delete_treenode()rx/rx_tree.c

Global Function rx_delete_tree()

int rx_delete_tree ( rx_tree_t* tree, rx_node_t* node, int maxlevel, int level, int nodecounter, void* userptr )
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: rx_delete_tree()rx/rx_tree.c
  rx_delete_treenode()rx/rx_tree.c
  fprintf()
Called by: RP_tree_del()rp/rp_tree.c
  rx_delete_tree()rx/rx_tree.c

Global Function rx_delete_treenode()

void rx_delete_treenode ( rx_tree_t* tree, rx_node_t* curnode )
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: ER_dbg_va()er/er.c
  UT_free_real(), g_list_foreach(), g_list_free()
Called by: rx_delete_tree()rx/rx_tree.c
References Functions: rx_delete_dataleaves()rx/rx_tree.c

Global Function rx_walk_tree()

  go down the tree calling func on every node.
  (func takes the node pointer and the current level)

the function is called recursively with level increased it stops recursing when no child nodes are found or maxlevel is reached.
therefore the initial call must set level to 0.
the nodecounter increments at every node, and is the return value of the function. So start with 0 to get the number of nodes traversed.
ERROR HANDLING IS DIFFERENT HERE! Unlike other functions it is not the return value: The error code from the func function IF DEFINED (== not NULL ) goes to the variable pointed to by the last parameter.
XXX: nodecounter is ALWAYS passed as 0, so should probably be removed from calling parameter list, shane 2001-02-01
int rx_walk_tree ( rx_node_t* node, er_ret_t (*func)(rx_node_t* node,int level,int nodecounter,void* userptr), rx_walk_mt walk_mode, int maxlevel, int level, int nodecounter, void* userptr, er_ret_t* err )
Prototyped in: /home/shane/release/RIP/include/rxroutines.h
Calls: ER_dbg_va()er/er.c
  rx_walk_tree()rx/rx_tree.c
  fprintf()
Called by: AC_decay()ac/access_control.c
  AC_print_access()ac/access_control.c
  AC_print_acl()ac/access_control.c
  ac_persistence_get_leaves()ac/ac_persistence.c
  rx_nod_search()rx/rx_search.c
  rx_tree_print()rx/rx_print.c
  rx_walk_tree()rx/rx_tree.c

Local Function asctime_r()

static char* asctime_r ( const struct tm* __tm, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_asctime_r()

Local Function ctime_r()

static char* ctime_r ( const time_t* __time, char* __buf )
Included from: /usr/include/time.h
Calls: __posix_ctime_r()

Local Function getlogin_r()

static int getlogin_r ( char* __name, int __len )
Included from: /usr/include/unistd.h
Calls: __posix_getlogin_r()

Local Function readdir_r()

static int readdir_r ( DIR* __dp, struct dirent* __ent, struct dirent** __res )
Included from: /usr/include/dirent.h
Calls: __posix_readdir_r()

Local Function sigwait()

static int sigwait ( const sigset_t* __setp, int* __signo )
Included from: /usr/include/signal.h
Calls: __posix_sigwait()

Local Function ttyname_r()

static int ttyname_r ( int __fildes, char* __buf, size_t __size )
Included from: /usr/include/unistd.h
Calls: __posix_ttyname_r()