pdtree.h

Go to the documentation of this file.
00001 /**
00002  * $Id: pdtree.h 4518 2008-07-28 15:39:28Z henningw $
00003  *
00004  * Copyright (C) 2005 Voice Sistem SRL (Voice-System.RO)
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * This file 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  * This file 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  * History:
00023  * -------
00024  * 2005-01-25  first tree version (ramona)
00025  */
00026 
00027              
00028 #ifndef _PDTREE_H_
00029 #define _PDTREE_H_
00030 
00031 #include "../../str.h"
00032 
00033 typedef struct _pdt_node
00034 {
00035    str domain;
00036    struct _pdt_node *child;
00037 } pdt_node_t;
00038 
00039 #define PDT_MAX_DEPTH   32
00040 
00041 #define PDT_NODE_SIZE   pdt_char_list.len
00042 
00043 typedef struct _pdt_tree
00044 {
00045    str sdomain;
00046    pdt_node_t *head;
00047 
00048    struct _pdt_tree *next;
00049 } pdt_tree_t;
00050 
00051 
00052 /* prefix tree operations */
00053 int add_to_tree(pdt_tree_t *pt, str *code, str *domain);
00054 int pdt_add_to_tree(pdt_tree_t **dpt, str* sdomain, str *code, str *domain);
00055 
00056 pdt_tree_t* pdt_get_tree(pdt_tree_t *pl, str *sdomain);
00057 
00058 str* get_domain(pdt_tree_t *pt, str *code, int *plen);
00059 str* pdt_get_domain(pdt_tree_t *pt, str* sdomain, str *code, int *plen);
00060 
00061 pdt_tree_t* pdt_init_tree(str* sdomain);
00062 void pdt_free_tree(pdt_tree_t *pt);
00063 int pdt_print_tree(pdt_tree_t *pt);
00064 
00065 int pdt_check_pd(pdt_tree_t *pt, str* sdomain, str *sp, str *sd);
00066 
00067 /* used to get the index for the PDT Tree hash*/
00068 #define strpos(s,c) (strchr(s,c)-s)
00069 
00070 #endif
00071 

Generated on Thu May 24 02:00:29 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6