dtrie.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dtrie.h 5237 2008-11-21 10:17:10Z henningw $
00003  *
00004  * Copyright (C) 2008 1&1 Internet AG
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00039 #ifndef _DTRIE_H_
00040 #define _DTRIE_H_
00041 
00042 
00044 struct dtrie_node_t {
00045         struct dtrie_node_t **child; 
00046         void *data; 
00047 };
00048 
00049 
00051 typedef void(*dt_delete_func_t)(void *);
00052 
00053 
00059 struct dtrie_node_t *dtrie_init(const unsigned int branches);
00060 
00061 
00070 void dtrie_delete(struct dtrie_node_t *root, struct dtrie_node_t *node,
00071                 dt_delete_func_t delete_payload, const unsigned int branches);
00072 
00073 
00080 void dtrie_destroy(struct dtrie_node_t **root, dt_delete_func_t delete_payload,
00081                 const unsigned int branches);
00082 
00083 
00094 void dtrie_clear(struct dtrie_node_t *root, dt_delete_func_t delete_payload,
00095                 const unsigned int branches);
00096 
00097 
00110 int dtrie_insert(struct dtrie_node_t *root, const char *number, const unsigned int numberlen,
00111                 void *data, const unsigned int dtrie_size);
00112 
00113 
00120 unsigned int dtrie_size(const struct dtrie_node_t *root, const unsigned int branches);
00121 
00122 
00131 unsigned int dtrie_loaded_nodes(const struct dtrie_node_t *root, const unsigned int branches);
00132 
00133 
00143 unsigned int dtrie_leaves(const struct dtrie_node_t *root, const unsigned int branches);
00144 
00145 
00158 void **dtrie_longest_match(struct dtrie_node_t *root, const char *number,
00159                 const unsigned int numberlen, int *nmatchptr, const unsigned int branches);
00160 
00161 
00170 void **dtrie_contains(struct dtrie_node_t *root, const char *number,
00171                 const unsigned int numberlen, const unsigned int branches);
00172 
00173 
00174 #endif